Async-graphql: Introspection query returns type MergedObjectTail without any fields

Created on 19 Oct 2020  路  4Comments  路  Source: async-graphql/async-graphql

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 馃檪

Expected Behavior

Introspection query returns valid result, which can be used in apps like the GraphQL Playground.

Actual Behavior

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.

Steps to Reproduce the Problem

  1. 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()
     }
    }
    
  2. 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:

  • Builds the Rust program
  • Writes the introspection query result to a file
  • Use the graphql node module to validate the schema and print any errors it finds

Specifications

  • Version: 2.0.5
  • Platform: macOS
bug

Most helpful comment

Please upgrade to v2.0.6, this problem has been resolved. 馃榿

All 4 comments

I 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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boardmaster357 picture boardmaster357  路  4Comments

AurelienFT picture AurelienFT  路  5Comments

hapcode picture hapcode  路  3Comments

SirWindfield picture SirWindfield  路  4Comments

TsumiNa picture TsumiNa  路  5Comments