Skip to content

Commit

Permalink
test: add case `check validation for createMany with root-level error…
Browse files Browse the repository at this point in the history
…s & extension`
  • Loading branch information
nodkz committed Sep 5, 2020
1 parent 5e9a7cd commit d3ce99e
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/__tests__/github_issues/248-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("issue #248 - payloads' errors", () => {
});
});

it('check validation for createMany', async () => {
it('check validation for createMany with error in mutation payload', async () => {
const res = await graphql.graphql({
schema,
source: `
Expand Down Expand Up @@ -170,4 +170,40 @@ describe("issue #248 - payloads' errors", () => {
},
});
});

it('check validation for createMany with root-level errors & extension', async () => {
const res = await graphql.graphql({
schema,
source: `
mutation {
createMany(records: [{ name: "Ok"}, { name: "John", someStrangeField: "Test" }]) {
records {
name
}
}
}
`,
});

expect(res).toEqual({
data: { createMany: null },
errors: [
expect.objectContaining({
message: 'Nothing has been saved. Some documents contain validation errors',
extensions: {
name: 'ValidationError',
errors: [
{
idx: 1,
message: 'this is a validate message',
path: 'someStrangeField',
value: 'Test',
},
],
},
path: ['createMany'],
}),
],
});
});
});

0 comments on commit d3ce99e

Please sign in to comment.