Thanks for all your work on async-graphql. We really enjoy working with it.
We use the introspection query to generate a GraphQL schema, which we can share with clients of the API. In version 2.0.5 this doesn't work anymore. Please let me know if I'm doing something wrong 馃檪
Introspection query returns valid result, which can be used in apps like the GraphQL Playground.
The introspection query returns a type without fields for each #[Object] without functions (or where the only function is an entity). This is also the case for merged objects, which are unlikely to have any functions implemented themselves. In this case a type MergedObjectTail without fields is returned.
Apps like the GraphQL Playground seem to validate the schema and then print error messages like this:
Type MergedObjectTail must define one or more fields.
Create a #[Object] only implementing a single entity function. Similar to this:
struct Query;
#[Object]
impl Query {
#[graphql(entity)]
async fn get(&self, id: ID) -> String {
"test".into()
}
}
Request the introspection query result
I made a small example here:
https://github.com/frigus02/test-async-graphql-deterministic-introspection/tree/67c9bb27b61b169118a5be9728b48ee02e3178be
When you run make it:
graphql node module to validate the schema and print any errors it findsI tried to find out the issue may be in the schema validation. I found https://github.com/graphql/graphql-js/issues/937 and https://github.com/graphql/graphql-spec/issues/568:
The spec says the field definition for Object types is optional
Description(opt) type Name ImplementsInterfaces(opt) Directives(const, opt) FieldsDefinition(opt)
-- https://spec.graphql.org/draft/#sec-Objects
But the validation rules for objects start with
1 An Object type must define one or more fields.
-- https://spec.graphql.org/draft/#sec-Objects.Type-Validation
Not sure what that means for async-graphql. Should it filter out types without fields from the introspection?
This is a bug, and I am solving it.
Please upgrade to v2.0.6, this problem has been resolved. 馃榿
Super quick, thanks a lot!
Most helpful comment
Please upgrade to
v2.0.6, this problem has been resolved. 馃榿