Skip to content

Commit ced5cf0

Browse files
committed
feat: custom scalar support
add the ability to add support for custom scalars
1 parent 2e56209 commit ced5cf0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ You may pass in options when creating a request handler. The options take the fo
139139
Person: { // arguments are mapped on a per-type basis
140140
pageSize: (records, _, pageSize) => records.slice(0, pageSize)
141141
}
142+
},
143+
/*
144+
`scalarMocks` is used if you have custom scalars and you need to mock them to
145+
return a default value
146+
*/
147+
scalarMocks: {
148+
MyCustomScalar: () => {
149+
return 'some custom value'
150+
}
142151
}
143152
}
144153
```

addon/mocks/create.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const composeCreateMocksForSchema =
1818

1919
let mocks = createMocks(typesAndMockFns, db, options);
2020

21+
if (options && options.scalarMocks) {
22+
mocks = Object.assign({}, mocks, options.scalarMocks)
23+
}
24+
2125
return mocks;
2226
};
2327

0 commit comments

Comments
 (0)