graphql-hive / graphql-hive/graphql-modules

Testkit fails to execute query

Open
#2,225 0 comments 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.