-
Notifications
You must be signed in to change notification settings - Fork 172
SchemaClassScanner doesn't scan directive arguments #664
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
Comments
This causes apollo-federated schemas to fail because
|
this can be reproduced with: package test;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Test;
import graphql.GraphQL;
import graphql.kickstart.tools.GraphQLQueryResolver;
import graphql.kickstart.tools.SchemaParser;
import graphql.kickstart.tools.SchemaParserBuilder;
import graphql.scalar.GraphqlStringCoercing;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLScalarType;
import graphql.schema.GraphQLSchema;
public class IssueTest {
static class MockQueryResolver implements GraphQLQueryResolver {
public String mockField(String input, DataFetchingEnvironment environment) {
return null;
}
};
@Test
public void testUsedInField() {
// this passes
graphQl(
"scalar MockScalar",
"directive @mockDirective(arg: MockScalar) on FIELD_DEFINITION",
"type Query {",
" mockField(input: MockScalar): String @mockDirective(arg: \"mock-value\")",
"}"
);
}
@Test
public void testUsedOnlyInDirectives() {
// this fails with:
// graphql.kickstart.tools.SchemaError: Expected type 'MockScalar' to be
// a GraphQLInputType, but it wasn't! Was a type only permitted for
// object types incorrectly used as an input type, or vice-versa?
graphQl(
"scalar MockScalar",
"directive @mockDirective(arg: MockScalar) on FIELD_DEFINITION",
"type Query {",
" mockField(input: String) : String @mockDirective(arg: \"mock-value\")",
"}"
);
}
private GraphQL graphQl(String... sdl) {
SchemaParserBuilder builder = new SchemaParserBuilder();
builder.schemaString(Stream.of(sdl).collect(Collectors.joining("\n")));
SchemaParser schemaParser = builder
.resolvers(new MockQueryResolver())
.scalars(GraphQLScalarType.newScalar()
.name("MockScalar")
.coercing(new GraphqlStringCoercing())
.build()
)
.build();
GraphQLSchema schema = schemaParser.makeExecutableSchema();
return GraphQL.newGraphQL(schema).build();
}
} |
@oryan-block is this easy to fix? i never coded in kotlin but if you give me a few pointers I can give it a shot. |
Unfortunately because of the way the scanner works and how different directives are from everything else, this is not a trivial fix. |
This should be partially resolved by #763 for scalars. |
@oryan-block Any updates on this or work arounds?
|
@airvine-r7 that fix is merged. You can test it now. |
Description
Custom scalars and input objects used in directives are not scanned, and subsequently their type cannot be determined when building directives in
SchemaParser
Expected behavior
Should parse successfully
Actual behavior
The text was updated successfully, but these errors were encountered: