EasyGraphQL / easygraphql-tester

Test GraphQL queries, mutations and schemas on an easy way! 🚀
https://easygraphql.com/docs/easygraphql-tester/overview
MIT License
314 stars 34 forks source link

Support for graphql-compose SchemaComposer.buildschema() #135

Closed benoror closed 3 years ago

benoror commented 4 years ago

I am getting this error when providing a GraphQLSchema built with graphql-compose.github using SchemaComposer.buildschema()

    Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: undefined

    > 46 |     const tester = new EasyGraphQLTester(schema);
         |                    ^

      at devAssert (node_modules/easygraphql-tester/node_modules/graphql/jsutils/devAssert.js:12:11)
      at buildClientSchema (node_modules/easygraphql-tester/node_modules/graphql/utilities/buildClientSchema.js:47:125)
      at buildGraphQLSchema (node_modules/easygraphql-tester/utils/buildGraphQLSchema.js:16:28)
      at new Tester (node_modules/easygraphql-tester/lib/tester.js:27:22)
      at Object.<anonymous> (my_file.js:46:20)

the code I am testing:

  it("should return schema types", async () => {
    const schema = await getSchema(); // returns a schemaComposer.buildSchema();
    const tester = new EasyGraphQLTester(schema);
    const query = gql`{ // using graphql-tag, also tried without it
      __schema {
        types {
          name
        }
      }
    }`;
    const result = await tester.graphql(query);

    expect(result).toHaveProperty("data");
  });

Appreciate any hint! Thanks!

benoror commented 4 years ago

Just tested SchemaComposer returned class and it succesfully returns instanceof GraphQLSchema:

const { GraphQLSchema } = require('graphql')

//...

  it('should return instanceof GraphQLSchema', async () => {
    const schema = await getSchema();

    expect(schema instanceof GraphQLSchema).toBe(true);
    expect(schema.kind).toBe(undefined);
    expect(schema.data).toBe(undefined);
  });

Which makes me suspect why this code falls into the last else instead of the first if conditional:

https://github.com/EasyGraphQL/easygraphql-tester/blob/162b069e1d3f028ff89f769aa122b46fb0fede88/utils/buildGraphQLSchema.js#L17-L23

🤔

benoror commented 4 years ago

Injected this console.log into the node module itself, and surprisingly there donesn't meet the condition! 😖

Screen Shot 2020-05-12 at 22 05 00
benoror commented 4 years ago

The only thing I can think of is that I am using "graphql": "^15.0.0" and easygraphql-tester is using version "^14.4.0"

redmundas commented 4 years ago

the problem is due to graphql@15.0.0. in earlier version it was exporting variable introspectionQuery, which is now replaced by function getIntrospectionQuery

estrada9166 commented 3 years ago

A new version has been release with the fix for this! 6.0.0