Skip to content
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

Testkit fails to execute query #2225

Open
Brian-McBride opened this issue Jul 23, 2022 · 0 comments
Open

Testkit fails to execute query #2225

Brian-McBride opened this issue Jul 23, 2022 · 0 comments

Comments

@Brian-McBride
Copy link

Brian-McBride commented Jul 23, 2022

Testkit not executing query (or mutations) using testkit.execute()

Problem

I'm having issues with testkit even running resolvers. Like a todo app:

    const app = testkit.testModule(todosGraphqlModule);
    expect(app.schema.getQueryType()).toBeDefined();
    expect(app.schema.getMutationType()).toBeDefined();

    const graphResult = await testkit.execute(app, {
      document: gql`
        query getTodo($id: ID!) {
          id
          title
        }
      `,
      variableValues: {
        id: 'someId',
      },
    });

    console.log(graphResult);  // output is:  { data {} }

Seems pretty simple. If I run the code in my app, the resolvers run as expected. But running this in Jest I always get { data {} } as a result, and the resolvers are never executed.

Reproduceable problem

Stackblitz

https://stackblitz.com/edit/node-mnkhc1?file=src/modules/users/users.module.spec.ts

Example repo

https://github.com/Brian-McBride/graphql-modules-testing-example

The schema link

The module link

The test is here:

Expected behavior

The response from the test should run the query and return its value.

Environment:

  • OS: OSX 12.4
  • "graphql-modules": "^2.1.0",:
  • NodeJS: v18.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant