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

21st
Jun 2017
Daniel Ocampo
@danielocampo2
Jun 21 2017 00:21
Hey, we are having a problem when defining the same input type for two different queries of our schema with graphql-java-annotations. This is happening since the library was updated to use graphql-java 3.0.
We have 2 queries that are as follows:
public List<SomeObject> getObjects(@GraphQLName("Code") Code code)
public List<SomeObject> otherQueryForObjects(@GraphQLName("Code") Code code, @GraphQLName("AnotherParameter") String param)
Bojan Tomić
@kaqqao
Jun 21 2017 00:24
@danielocampo2 This is a known bug: graphql-java/graphql-java-annotations#84. The current release of graphql-java-annotations is incompatible with graphql-java 3.0.0. The bug has already been fixed, so either wait for the next release or do a local build of the master, as I don't think that project is deploying nightlies anywhere
Daniel Ocampo
@danielocampo2
Jun 21 2017 00:24
@kaqqao i am using latest master
Bojan Tomić
@kaqqao
Jun 21 2017 00:25
Ah, ok. Then it's something worse :( Sorry, I don't know then...
Oh, i've just realized you opened graphql-java/graphql-java-annotations#84 :) so of course you already knew what I said
Daniel Ocampo
@danielocampo2
Jun 21 2017 00:27
I am wondering if this is an error with the library trying to create 2 Input objects for the same class, as the error I receive is as follors:
Caused by: 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 'inputCode' from being a 'GraphQLInputObjectType' to a 'GraphQLInputObjectType'
@kaqqao yeah no worries ha
Daniel Ocampo
@danielocampo2
Jun 21 2017 04:07
I would like to know if this could be a bug of the library or it is the intended behavior. If it is the former I would probably try to work on a fix for it
I understand it is, if not a bug, at least a limitation
kavya-ithaka
@kavya-ithaka
Jun 21 2017 17:55
Hi there. I'm trying to create a schema with a single mutation type and no query type. And that's not allowed as of now because the constructor does a not null check for the queryType. public GraphQLSchema(GraphQLObjectType queryType, GraphQLObjectType mutationType, GraphQLObjectType subscriptionType, Set<GraphQLType> dictionary) { assertNotNull(dictionary, "dictionary can't be null"); assertNotNull(queryType, "queryType can't be null"); this.queryType = queryType; this.mutationType = mutationType; this.subscriptionType = subscriptionType; this.additionalTypes = dictionary; typeMap = new SchemaUtil().allTypes(this, dictionary); } Seems unnecessarily strict. Any thoughts?
Andreas Marek
@andimarek
Jun 21 2017 19:50
@kavya-ithaka the spec says: The query type must always be provided, and is an Object base type. The mutation type is optional; if it is null, that means the system does not support mutations.
Brad Baker
@bbakerman
Jun 21 2017 21:50
@danielocampo2 - the graphql spec says that all types must be unique - but with Java class —> graphql type conversion its easy toend up with the same type defined twice
its not a bug - but it is different to 2.x - where we did not enforce this aspect of the spec
Daniel Ocampo
@danielocampo2
Jun 21 2017 21:53
@bbakerman thanks, yes, I understand the reasons, but I don't understand why I would not be able to use the same type for two different queries where it makes sense. Is it that I am declaring something wrong? Simplifying the question, how can I use the same parameter (say object "Code" in 2 different queries, but without being it defined twice?)
I mean, this works just fine changing the parameter to String. So I guess I am missing something
Brad Baker
@bbakerman
Jun 21 2017 21:55
I think the problem will be in the discovery of types phase - it may find a “Code” class twice and while logically its the same class, if it makes 2 instances of that same class as a type - it ends up as 2 types and fails validation
in queries of course you can re-use a type in many places
but I suspect that in this case its the Java annoation -> graphqtype process that is inducing the accidental redefintiion
Daniel Ocampo
@danielocampo2
Jun 21 2017 22:04
yes, that is exactly what is happening, so I was wondering how to solve this. Should this be handled by annotations library?
While it loops through the parameters, if it finds this "Code" class, it will always try yo create a new type. The second time as you said it will fail as it already exists with the new validation added in 3.0.0. Is is possible to handle this in annotations library and, if it already exist the class, use that type instead of attempting to create a new one every time?
Does that make sense?
Brad Baker
@bbakerman
Jun 21 2017 22:18
I would need a reproduction case
there is a “reference” mechanism in graphql
which annotations.objectOrReference() method sues
uses
public GraphQLOutputType getObjectOrRef(Class<?> object) throws GraphQLAnnotationsException {
Daniel Ocampo
@danielocampo2
Jun 21 2017 22:21
we would need the same but for InputType right?
Brad Baker
@bbakerman
Jun 21 2017 22:22
we might not have the same for input types
can you create a ticket
Daniel Ocampo
@danielocampo2
Jun 21 2017 22:23
yes, I will, and will add how to reproduce, I think it should be fairly easy to create a failing test for it