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

17th
May 2017
Adam Fiebig
@fiebiga
May 17 2017 00:23
@danielocampo2 If it's not possible then I really don't see the point of the annotations library, personally. There must be an equivalent configuration with annotations vs no-annotations. We're considering using the library for our project but we have existing models defined and distributed already... I'd love to see some enhanced documentation on the annotations lib! It's already quite close, I feel.... if that star wars example could be fleshed out for annotations
Daniel Ocampo
@danielocampo2
May 17 2017 00:31
@fiebiga I've been taking a look at that today and I think that the intention of both libraries is kind of different, so it kind of clashes at some point if you wanna work with them at the same time. The thing is that graphql-tools will map your schema to your data classes, and while this data classes could be (I guess) annotated with graphql-annotations, grapgql-tools won't care at all about this (as it searches for methods with particular names, not annotations), making the annotations useless. Same will happen with, e.g., @GraphqlDataFetcher annotation since the concept of fetcher I think it disappears in graphql-tools replaced by this idea of Resolvers.
I find annotations give you a bit more flexibility to your code and how you want to organise it. In our case, we need this to be quite flexible and very extensible, and I don't see yet how we could achieve this with graphql-tools. So basically that means that we will have this undesired gap between our Schema definitions and the code that reflect this schemas. Would love to have a tool that could validate it.
Bojan Tomić
@kaqqao
May 17 2017 00:40
I'll grab a chance to shamelessly plug GraphQL-SPQR (my project) as it sounds like it could benefit you. It's still pre 1.0, but pretty much allows you to forget schemas exist :) It exposes your services over GraphQL with practically no glue code. Check out an example at https://github.com/leangen/graphql-spqr-samples But, if you're going for schema-first, it may not be what you need
Adam Fiebig
@fiebiga
May 17 2017 00:44
@danielocampo2 Hmm. If that's the case then I will take a hard look again at my understanding (which admittedly is not that great) of how this library functions. So it's an either/or scenario... I have envisioned them both as taking steps towards taking different steps away from the boilerplate of graphql-java base. Maybe that's where my great confusion is coming from when trying to put these together. Then let me rephrase - I'd love to see a star wars example using the annotations lib only lol
Daniel Ocampo
@danielocampo2
May 17 2017 00:48
@fiebiga if you mean building your schema based on annotated classes, it is possible. We've done that. I will see if I can share that later. Basically we search for all the "Query" classes (implementing a marker interface) and based on the annotated fields of each of these, we build a GraphQLObjectType that will later be used to build the schema.
so you remove all the boilerplate of the schema creation that comes with the graphql-java way of doing it
final GraphQLSchema schema = newSchema() .query(createDelegatingObject("Query", this.schemaExtensions)) .build();
schemaExtensions is an array containing all the Query classes
Adam Fiebig
@fiebiga
May 17 2017 01:06
Ah I see... interesting! This does give me a bit to chew on, for sure - thank you. If you can share, that would be obscenely helpful, but I'd understand why not!
Adam Fiebig
@fiebiga
May 17 2017 23:28
@danielocampo2 I'm assuming you accomplish the discovery with reflection?