-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL documents with multiple queries + operationName throws exception #3556
Comments
I guess it's not a part of |
@kamilkisiela This is a separate and unrelated issue. They are talking there about running multiple queries within one request. I want to run only one query from one document that has multiple queries defined. The See an example in the GraphiQL demo: https://graphql.github.io/swapi-graphql/?query=query%20A%20%7B%0A%20%20allPlanets%20%7B%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Aquery%20B%20%7B%0A%20%20allFilms%20%7B%0A%20%20%20%20totalCount%0A%20%20%7D%0A%7D%0A&operationName=A This query is currently not supported by the apollo link data layer. If we remove the check that I mentioned above this would solve the problem. We only might have to ensure in a higher level that in case of a document with multiple queries an |
To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository. This feature request / discussion will be closed here, but anyone interested in migrating this issue to the new repository (to make sure it stays active), can click here to start the migration process. This manual migration process is intended to help identify which of the older feature requests are still considered to be of value to the community. Thanks! |
Intended outcome:
I am trying to use the
link
object on anApolloClient
instance to execute a query that is part of a document that contains multiple queries. Specific use case: I want to reuse the link with auth logic etc as a fetcher for GraphiQL where you would often write multiple queries in one document for testing. Right now when the query is executed it throws an exception because of this check:https://github.com/apollographql/apollo-client/blob/master/packages/apollo-utilities/src/getFromAST.ts#L49
When I remove it, everything works as expected. IMO this check should happen at a higher level if required by apollo client and not when a valid GraphQL operation is executed directly on the link object.
Actual outcome:
Right now when I execute the query, it throws an exception "Ambiguous GraphQL document: contains N operations" even if the operationName is provided. This should be a valid GraphQL operation.
How to reproduce the issue:
Versions
System:
OS: macOS High Sierra 10.13.4
Binaries:
Node: 9.8.0 - ~/.nvm/versions/node/v9.8.0/bin/node
Yarn: 1.7.0 - ~/.yarn/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v9.8.0/bin/npm
Browsers:
Chrome: 66.0.3359.181
Safari: 11.1
npmPackages:
apollo-cache-inmemory: ^1.1.4 => 1.2.2
apollo-client: ^2.1.0 => 2.3.2
apollo-client-preset: ^1.0.5 => 1.0.8
apollo-link: ^1.0.7 => 1.2.2
react-apollo: ^2.0.4 => 2.1.4
The text was updated successfully, but these errors were encountered: