You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SDL scalar descriptions are not available for introspection #2410
Scalar descriptions are not correctly included into a GraphQLSchema from a TypeDefinitionRegistry parsed from an SDL string.
GraphQLScalarType's definition field remains as null, while strangely, the description on GraphQLScalarType.definition includes the correct value.
This is important, as for users who load their schema from graphql SDL files, rather than building it with the builders, the descriptions never make it through to introspection.
To Reproduce
Using GraphQL-Java version 16.2
finalStringschemaSDL = ""
+ "\"\"\"\n"
+ "2-digit integer e.g. January is 01\n"
+ "\"\"\"\n"
+ "scalar Month\n"
+ "\n"
+ "type Query {\n"
+ " currentMonth: Month\n"
+ "}\n";
finalTypeDefinitionRegistrytdr = newSchemaParser().parse(schemaSDL);
finalGraphQLSchemaschema = newSchemaGenerator().makeExecutableSchema(tdr, RuntimeWiring.newRuntimeWiring().scalar(
GraphQLScalarType.newScalar().name("Month").coercing(newGraphqlStringCoercing()).build()).build());
finalGraphQLScalarTypescalar = (GraphQLScalarType) schema.getType("Month");
assertEquals("2-digit integer e.g. January is 01", scalar.getDefinition().getDescription().getContent()); // PassesassertEquals("2-digit integer e.g. January is 01", scalar.getDescription()); // Fails
This is tricky in some regards because a Scalar needs to have a specific instance (unlike types that we can create purely from SDL) because of the code in the coercing
I can see that the description is coming in to graphQLScalarType.getDefinition().getDescription(). It's not using the GraphQLScalarType I created with newScalar(), that one didn't have a definition set when I built it.
It seems to me that it's creating a new GraphQLScalarType with some stuff from the SDL and some stuff from the scalar definition from the RuntimeWiring, in which case, couldn't we include the description from the SDL into the new scalar definition as part of that transformation, much like we include the definition?
Activity
bbakerman commentedon Jun 30, 2021
When you wired in the implementation here
this created a scalar with no description.
This is tricky in some regards because a Scalar needs to have a specific instance (unlike types that we can create purely from SDL) because of the code in the coercing
WMendelsohn commentedon Jun 30, 2021
Thanks for your reply.
I can see that the description is coming in to
graphQLScalarType.getDefinition().getDescription(). It's not using theGraphQLScalarTypeI created withnewScalar(), that one didn't have a definition set when I built it.It seems to me that it's creating a new
GraphQLScalarTypewith some stuff from the SDL and some stuff from the scalar definition from theRuntimeWiring, in which case, couldn't we include the description from the SDL into the new scalar definition as part of that transformation, much like we include the definition?bbakerman commentedon Jun 30, 2021
Your right - we could do something - we transform it today. we could transfer the description if not empty
bbakerman commentedon Jul 4, 2021
fixed
WMendelsohn commentedon Jul 5, 2021
Thank you! 😄