apollo-feature-requests
apollo-feature-requests copied to clipboard
Support operationName in client queries
I'm using the <Query> component of react-apollo, and I'm looking a simple way to write one GQL file that defines several related operations I might need for a component, which I could then reference by operationName, which Apollo Server supports.
For example, imagine a page of products, and a subnav widget that lets you filter by product category. One queries.gql file could define both a getAllProducts and a getProductsByCategory query. I imagine it looking something like:
<Query query={PRODUCT_QUERIES} operationName={SELECTED_OPERATION || DEFAULT_OPERATION} {...otherProps} />
I know I can just add more component logic to swap out queries, but that seems wrong somehow, given the first-class nature of operationName elsewhere in the GraphQL universe.
A quick google search shows that other folks have wondered why Apollo server supports operationName, but the client does not:
https://github.com/apollographql/apollo-client/issues/872
UPDATE: apologies if this request conflates base+react client stuff.
I would also like to have this feature. I am very surprised it is not already implemented.
Bump, this feature must be implemented.