-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SchemaParser should not return appliedDirectives under directives #729
Comments
Are there any updates on this? |
Still strugging with this one. Having to build workarounds :( |
@oryan-block I tried to use 13.1.1-SNAPSHOT in the same project and I'm now getting this exception
according to the debugger for
I tried to poke around a bit more, the code to setup the schema would call fun schemaTransformer(schemaParser: SchemaParser): SchemaTransformer {
val (query, mutation, subscription, dictionary, directives, codeRegistryBuilder) = schemaParser.parseSchemaObjects() // new exception happens here
val queryTypeIsEmpty = query.fieldDefinitions.isEmpty()
val newQuery = if (queryTypeIsEmpty) query.transform { graphQLObjectTypeBuilder: GraphQLObjectType.Builder ->
graphQLObjectTypeBuilder.field(
GraphQLFieldDefinition.newFieldDefinition()
.name("_dummy")
.type(Scalars.GraphQLString)
.build()
)
} else query
val graphQLSchema = GraphQLSchema.newSchema()
.query(newQuery)
.mutation(mutation)
.subscription(subscription)
.additionalTypes(dictionary)
.additionalDirectives(directives)
.codeRegistry(codeRegistryBuilder.build())
.build()
return Federation.transform(graphQLSchema, queryTypeIsEmpty)
} So the new exception kind of makes sense here, but for this case it's a bit less ideal that the parser already performs semantic checks. However, frankly I don't have the overview which GQL libraries are at play here, which one is buggy or if there's a better way to sidestep the behavior. I can just tell you the existing code still works with 13.0.1. |
@xcq1 sorry for the late reply but are you not able to add these definitions to your schema? I'm not familiar with how Apollo works or intended to work. One option, if this is really required, would be to add a schema option that will "inject" these definitions if turned on. |
@oryan-block directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
# this is an optional directive discussed below
directive @extends on OBJECT | INTERFACE
scalar _FieldSet This now gives me the following error: As far as I can see all of this would be added by the call to If you think this is an issue on the part of apollographql/federation-jvm (e.g. because they should implement this differently), I can also report it there. |
@xcq1 If you look at the test here, as long as you pass the scalar type to the parser it doesn't have a problem. I don't know anything about |
Description
I'm seeing unexpected behavior from
SchemaParser
that prevents me to properly upgrade to the newest versions of graphql-java 19.2 & graphql-java-kickstart 15.I'm using GraphQL Federation via
com.apollographql.federation:federation-graphql-java-support:2.2.0
which includes directives such as@extends
or@key
in the schema. Starting with graphql-java-tools 13.0.2, these are not only reported asappliedDirectives
, but asdirectives
as well. This causes the validation to fail and the server to not start, because they are not defined in the same schema:I believe this is incorrect with regards to the docs in https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/schema/GraphQLDirective.java#L28-L32. From my limited knowledge, I think this states that the field
directives
should only contain directive definitions and no longer directive applications, however I'm not entirely sure whether I'm reporting this at the right place.It works correctly with either
com.graphql-java-kickstart:graphql-java-tools
13.0.0com.graphql-java-kickstart:graphql-java-tools
to 13.0.1Expected behavior
Parsing such a schema:
with
schemaParser.parseSchemaObjects()
should return emptyquery.directivesHolder.allDirectivesByName == []
andquery.directivesHolder.allAppliedDirectivesByName == ["extends" to ...]
Actual behavior
Parsing with
schemaParser.parseSchemaObjects()
returnsquery.directivesHolder.allDirectivesByName == ["extends" to ...]
.Steps to reproduce the bug
See SDL example above. In case this is insufficient, I can also provide a minimal repro project.
The text was updated successfully, but these errors were encountered: