easygraphql-tester
easygraphql-tester copied to clipboard
How to use test.mock if result is a Union type
In this example in my code, the query returns always empty:
it('Should return store by id', () => {
const query = `
query($id: ID, $slug: String) {
store(id: $id, slug: $slug) {
... on Store {
id
name
slug
}
}
}
`;
const fixture = {
data: {
store: {
id: '1',
name: 'AnyoneStore'
}
}
};
const variables = {
id: "1"
};
const { data: { store } } = tester.mock({ query, fixture, variables });
// store
/ / {}
Can you share your schema please, so I can reproduce it locally?
As you can see here it should be working fine for unions.
Also, you can use this codesandbox template to reproduce the test, and we can test it there