polymer-apollo
polymer-apollo copied to clipboard
Automatically define property values as variables
I have for example the following (simplified) element:
<script>
Polymer({
is: "rd-page-link",
properties: {
pageId: String,
pageObject: Object
},
apollo: {
PageLink: {
query: Apollo.gql`query GetPageLink($identifier: ID!) {
pageObject: Page(id: $identifier) {
title,
urlKey
}
}`,
options: '_queryOptions(pageId)',
}
},
_queryOptions: function (pageId) {
return {
variables: {
identifier: pageId
},
};
},
})
</script>
Wouldn't it be nice if you didn't have to define the link between the GraphQL variable $identifier and the polymer property pageId. Would be nice if the following just worked.
<script>
Polymer({
is: "rd-page-link",
properties: {
pageId: String,
pageObject: Object
},
apollo: {
PageLink: {
query: Apollo.gql`query GetPageLink($pageId: ID!) {
pageObject: Page(id: $pageId) {
title,
urlKey
}
}`,
}
},
})
</script>
And to move further, would be nice if we didn't need the key in the apollo object, doesn't serve any purpose?
<script>
Polymer({
is: "rd-page-link",
properties: {
pageId: String,
pageObject: Object
},
apollo: [{
query: Apollo.gql`query GetPageLink($pageId: ID!) {
pageObject: Page(id: $pageId) {
title,
urlKey
}
}`,
}],
})
</script>
@bramvanderholst Thanks for the feedback. :) . Added this in the pipeline.