Directive locations causes null result
See original GitHub issueHi!
I have been trying to make graphql-java
work with Graphiql, I have noticed that at startup Graphiql sends the following query to the the GraphQL server:
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}
When sending this query to graphql-java
using the Hello World schema described in the README, the result ends up being null.
I have identified the field causing the error as the locations
of directives
. Here is a very simple program to reproduce the issue:
import graphql.GraphQL;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import java.util.Map;
import static graphql.Scalars.GraphQLString;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
public class GraphQLTest {
public static void main(String[] args) {
GraphQLObjectType queryType = newObject()
.name("helloWorldQuery")
.field(newFieldDefinition()
.type(GraphQLString)
.name("hello")
.staticValue("world")
.build())
.build();
GraphQLSchema schema = GraphQLSchema.newSchema()
.query(queryType)
.build();
String query = "{\n" +
" __schema {\n" +
" directives {\n" +
" locations\n" +
" }\n" +
" }\n" +
" }";
Map<String, Object> result = (Map<String, Object>) new GraphQL(schema).execute(query).getData();
System.out.println(result);
}
}
The output I get from this is:
[main] INFO graphql.GraphQL - Executing request. operation name: null. Request: {
__schema {
directives {
locations
}
}
}
null
Has anyone been able to make graphql-java
work with graphiql?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Creating schema directives - Apollo GraphQL Docs
The table below lists all available locations in a GraphQL schema. Your directive can support any combination of these locations.
Read more >Directive on FIELD_DEFINITION returns whole object null #431
Expected Behaviour Directive on field makes whole object to null instead of the done field. The todo example in the repo. done: Boolean!...
Read more >Does GraphQL Interpret null as truthy? - Stack Overflow
In GraphQL, I query all the pages for each component and its subfields. GraphQL returns the correct amount of components for each page,...
Read more >Schema Directives – GraphQL Tools
Using and implementing custom directives to transform schema types, fields, and arguments.
Read more >Directives - Hot Chocolate - ChilliCream GraphQL Platform
By default, directives are not repeatable, which means directives are unique and can only be applied once at a specific location. For example, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@IamCornholio #136 added the
locations
field but did not provide a data fetcher. I suppose that was enough for GraphiQL to work, but I don’t know how it would actually provide true results for that field without #175.Closing this. Let’s continue on #175. Thanks everyone.
I have tried this with the last version of
graphql-java
and graphiql worked just fine. It think this issue can be closed. Thanks!