graphql-hive / graphql-hive/graphql-modules

visitedTypes in the testkit does not include enums

Open
#1,941 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

While writing a test I discovered that enums are not listed in the visitedTypes. And cause testModule to fail.

My test:
```
it('Resolves query', async () => {
const mockData = {
contact: {
email: 'this@that.com',
name: 'Bruce',
phone: '913-555-1212',
},
};

const mockResult = {
_id: '1e9f12ca136a0d24b4a08821',
...mockData,
};

const app = testkit.testModule(myModule, {
inheritTypeDefs: [module1, module2],
providers: [
{
provide: myProvider,
useValue: {
getOne() {
return {
...mockData,
};
},
},
},
],
});

const result = await testkit.execute(app, {
document: gql`
query {
getFromDatabase(filter: { _id: "1e9f12ca136a0d24b4a08821" }) {
_id
contact {
email
name
phone
}
}
}
`,
});

expect(result.errors).toBeFalsy();
expect(typeof result.data.getFromDatabase).toBe('object');
expect(result.data.getFromDatabase).toEqual(mockResult);
})
```

A workaround I have found is to include the Module with the enum types in both the inheritTypeDefs and the modules.

**Environment:**
- OS: MAC
- `@graphql-modules/...`:
- NodeJS: 14.17.6

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.