Subquery/Edges/...
See original GitHub issueHello,
I have been trying for the past 2 days to use this and i am completely lost and confused. The only thing i was able to achieve is a simple query that simply returns some users for instance. But when there is subquery or edges involved i could not find any example/documentation on how to do it. I tried everything i could trying to decipher the tests code but either nothing in my code for the subquery is called or i have a GraphQL exception which i have no idea how to resolve using spqr.
I see there is a Edge class but i don’t know what to do with it, is it mandatory? Why do my GraphQLQuery annotated method for a subquery is never called? How do i pass parent information like a field to the subquery? What relayId on GraphQLId do?
Is there an example somewhere that could help me? I have so many questions and no answer that i could find. Something simple like post/comments and you want to have all the comments of a specific post in a single query would be a good example i think.
I feel this product could help me a lot but since there is no documentation/example whatsoever, i have no idea what to do.
Right now i want to use GraphQLContext User user in a subquery method to retrieve the parent.
public List<Vote> getUserVotes(@GraphQLContext User user) {...}
My user object has a Gender enum class and when the method is declared i receive the following exception :
graphql.AssertException: All types within a GraphQL schema must have unique names. No two provided types may have the same name. No provided type may have a name which conflicts with any built in types (including Scalar and Introspection types). You have redefined the type 'GenderInput' from being a 'GraphQLEnumType' to a 'GraphQLEnumType'
Thanks a lot.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
As for the
SELECT ... FROM ...
optimization, it is possible, but at this moment not very convenient if the field isn’t an object (i.e. if you’re selecting from an interface or a union).If the current field is an object type, you can get the sub-field names injected simply via
@GraphQLEnvironment Set<String> subFields
parameter, e.g.But, if the current field is not an object, there’s no such easy way to inject the sub-fields. But what you can still do in inject
@GraphQLEnvironment ResolutionEnvironment env
, from here you can get a hold ofDataFetchingEnvironment
(standard graphql-java API) viaenv.dataFetchingEnvironment
and from there you can get the current field and it’s sub-selections, but it gets tricky with aliases, conditional selects etc. graphql-java also doesn’t deal with these cases, so I’ll have to rework the sub-selection injection in graphql-spqr itself to be more usable. It’s high on my list, so you’ll get that feature soon 😃I’ll close this one as the enum bug has been fixed and I’ve opened #9 to track the progress of the sub-field injection feature. @depauwjimmy @string01 If you still need this one open, please comment.
@string01 Thanks a bunch for your comment 😃