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.

Subquery/Edges/...

See original GitHub issue

Hello,

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:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kaqqaocommented, Jul 28, 2017

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.

@GraphQLQuery(name = "userVotes")
public List<Vote> getUserVotes(@GraphQLContext User user, @GraphQLEnvironment Set<String> subFields) {
    //do a SELECT here using the field names from subFields instead of *
   ...
} 

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 of DataFetchingEnvironment (standard graphql-java API) via env.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 😃

0reactions
kaqqaocommented, Jul 28, 2017

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subqueries (SQL Server) - Microsoft Learn
A subquery is a query that is nested inside a SELECT , INSERT , UPDATE , or DELETE statement, or inside another subquery....
Read more >
Subqueries - Interactive EdgeQL Tutorial - EdgeDB
Working with ShapesSubqueriesWith BlockShapes and JSON. Sometimes it is not enough to fetch the data as-is, but it is necessary to add something...
Read more >
Mysql Edge List, combining subquery result - Stack Overflow
What I need: I would like to essentially iterate over the edge id's, retrieve the Node-id, then access the Position for every node...
Read more >
Subqueries | BigQuery - Google Cloud
Expression subqueries are used in a query wherever expressions are valid. They return a single value, as opposed to a column or table....
Read more >
Select from query... option - Blackbaud Knowledgebase
How can I use a sub-query in The Raiser's Edge? ... This can be a handy tool if your Raiser's Edge has lots...
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