question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not create multiple queries with the same name

See original GitHub issue

When I try to use the same query name, with different arguments, I get a an exception

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'schema' threw exception; nested exception is java.lang.IllegalStateException: Not all resolvers expect the same source types
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
	... 67 common frames omitted
Caused by: java.lang.IllegalStateException: Not all resolvers expect the same source types
	at io.leangen.graphql.metadata.strategy.query.DefaultOperationBuilder.resolveContextTypes(DefaultOperationBuilder.java:77) ~[spqr-0.9.3.jar:na]
	at io.leangen.graphql.metadata.strategy.query.DefaultOperationBuilder.buildQuery(DefaultOperationBuilder.java:34) ~[spqr-0.9.3.jar:na]
	at io.leangen.graphql.generator.OperationRepository.lambda$buildQueries$39(OperationRepository.java:38) ~[spqr-0.9.3.jar:na]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_112]
	at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1691) ~[na:1.8.0_112]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_112]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_112]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_112]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_112]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_112]
	at io.leangen.graphql.generator.OperationRepository.buildQueries(OperationRepository.java:39) ~[spqr-0.9.3.jar:na]
	at io.leangen.graphql.generator.OperationRepository.<init>(OperationRepository.java:31) ~[spqr-0.9.3.jar:na]
	at io.leangen.graphql.GraphQLSchemaGenerator.generate(GraphQLSchemaGenerator.java:685) ~[spqr-0.9.3.jar:na]
	at io.committed.BaleenGrahpQl.schema(BaleenGrahpQl.java:43) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
	... 68 common frames omitted

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kaqqaocommented, Oct 15, 2017

You are right. Currently, if one of the resolver methods has a @GraphQLContext attribute, all the resolvers must have the same.

This is actually a needless and unintuitive limitation, and I have already made the changes to fix it, but haven’t yet pushed them. I’ll resume the work in about 10 days.

0reactions
kaqqaocommented, Nov 16, 2017

I’m aiming to release v0.9.4 (containing this fix) tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 queries with same technical name - SAP Community
Hi, I have just opened this QA system. I find that there are two queries with the same technical name. The query definition...
Read more >
Use a union query to combine multiple queries into a single ...
Under the Views command on the Home tab, you'll notice that Design View is not available when you work with union queries. You...
Read more >
Multiple queries error in Gatsby "Multiple "root" queries found"
The issue is that you can only have a single query and you have multiple. The solution is to query for all the...
Read more >
Queries fail if there are multiple queries
A simple workaround is to put each query in a separate document, and I'll proceed that way.
Read more >
SQL WITH: Organize Complex Queries
The syntax after the keyword with is the same as it is for create view : it starts with the query name, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found