Skip to content

Commit cede4a8

Browse files
committed
Unwrap non-null returnType during mutations
1 parent 29905db commit cede4a8

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

addon/mocks/mutation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { contextSet, isFunction, reduceKeys } from '../utils';
1+
import { contextSet, isFunction, reduceKeys, unwrapNonNull } from '../utils';
22
import { getRecords } from '../db';
33
import { resolveVarName } from '../filter/vars';
44

@@ -11,6 +11,8 @@ const mapVars = composeMapVars(resolveVarName);
1111

1212
export const composeMockMutation = (getRecords, mapVars) =>
1313
(db, options = {}, _, vars, __, { fieldName, returnType }) => {
14+
returnType = unwrapNonNull(returnType);
15+
1416
let { mutations = {}, varsMap = {} } = options;
1517
let mutation = mutations[fieldName];
1618
let records = getRecords(db, returnType.name);

tests/dummy/app/gql/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type LineItemEdge {
2929
}
3030

3131
type Mutation {
32-
updatePerson(id: ID!, personAttributes: PersonAttributes!): Person
32+
updatePerson(id: ID!, personAttributes: PersonAttributes!): Person!
3333
}
3434

3535
interface Node {

0 commit comments

Comments
 (0)