graphql-hive / graphql-hive/graphql-modules
Testkit fails to execute query
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 113
- Avg merge
- 3h 36m
- Merged PRs (30d)
- 1
Description
# Testkit not executing query (or mutations) using `testkit.execute()`
## Problem
I'm having issues with testkit even running resolvers. Like a todo app:
```typescript
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](https://github.com/Brian-McBride/graphql-modules-testing-example/blob/cf5b89dc4eb555578d6240ab98b1805fe2001fc0/libs/server/modules/users/src/lib/schema/users.graphql.ts)
The [module link
](https://github.com/Brian-McBride/graphql-modules-testing-example/blob/cf5b89dc4eb555578d6240ab98b1805fe2001fc0/libs/server/modules/users/src/lib/users.module.ts)
The test is [here](https://github.com/Brian-McBride/graphql-modules-testing-example/blob/cf5b89dc4eb555578d6240ab98b1805fe2001fc0/libs/server/modules/users/src/lib/users.module.spec.ts):
## 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.