These are chat archives for graphql-java/graphql-java

26th
May 2017
Paul Tomlin
@ptomli
May 26 2017 14:23
I have a query about the example schema; When querying for hero there is an optional argument for episode, I'm trying to see where that predicate (or whatever the term might be) is actually implemented
Andreas Marek
@andimarek
May 26 2017 14:27
@ptomli could you give more context? which example?
Paul Tomlin
@ptomli
May 26 2017 14:29
Generally http://graphql-java.readthedocs.io/en/latest/schema.html, but it's just the normal hero(episode: Episode) bit. I've found an example in the groovy test files StarWarsData.groovy heroDataFetcher does the work of checking. I guess I'm trying to internalise
Andreas Marek
@andimarek
May 26 2017 14:31
@ptomli our documentation is far from perfect: it would be great if you could create a PR or Issue if you find something unclear or missing ... thanks!
Paul Tomlin
@ptomli
May 26 2017 14:31
Perhaps, it's also likely I just need to understand more before I can produce a sensible question.
My use case I'm trying to sketch out involves finding entities in the graph which match a predicate, which I think is what the argument is doing in the hero example. I was just trying to see how that would actually be done in graphql-java (in Java, I'm not familiar with Groovy). I think I have figured out what I'll get lost in over the weekend
Andreas Marek
@andimarek
May 26 2017 14:38
@ptomli you get the arguments to a field via DataFetchingEnvirionment. Inside the DataFetcher you can do whatever you want: in this case filter based on the arguments
Paul Tomlin
@ptomli
May 26 2017 14:40
At http://graphql-java.readthedocs.io/en/latest/schema.html#datafetcher-and-typeresolver, there is a bit of code .dataFetcher("hero", new StaticDataFetcher(StarWarsData.getArtoo())). I think that is meant to be something like .dataFetcher("hero", StarWarsData. heroDataFetcher()). What's there now doesn't quite make sense.. how would the episode argument affect the result, if it's always 'R2D2'
Andreas Marek
@andimarek
May 26 2017 14:41
@ptomli true ...this example is not really good: the episode arguments gets ignored
Paul Tomlin
@ptomli
May 26 2017 14:42
I think what I'm saying is that I don't think the example code matches the expected implementation, based on the schema... ah yes, OK
Andreas Marek
@andimarek
May 26 2017 14:42
@ptomli yes, exactly
Paul Tomlin
@ptomli
May 26 2017 14:43
@andimarek thanks, that makes sense then. I was a bit lost trying to see where in the example the argument was matched. Delving into the test filled in the gap
Thanks. Interesting thing, this GraphQL. Modern and hip for old school Java dudes like me ;-)