Skip to content

Commit 9410256

Browse files
update README
1 parent 9744479 commit 9410256

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ keep all GraphQL names as-is. Available case functions in `change-case-all` are
8686
`localeLowerCase`, `lowerCaseFirst`, `spongeCase`, `titleCase`, `upperCase`, `localeUpperCase` and `upperCaseFirst`
8787
[See more](https://github.com/btxtiger/change-case-all)
8888

89-
### scalars (`{ [Scalar: string]: GeneratorOptions }`, defaultValue: `undefined`)
89+
### scalars (`{ [Scalar: string]: GeneratorOptions | InputOutputGeneratorOptions }`, defaultValue: `undefined`)
9090

9191
Allows you to define mappings for your custom scalars. Allows you to map any GraphQL Scalar to a
9292
[casual](https://github.com/boo1ean/casual#embedded-generators) embedded generator (string or
@@ -371,6 +371,24 @@ fieldName: # gets translated to casual.integer.toFixed(3)
371371
arguments: 3
372372
```
373373

374+
### `InputOutputGeneratorOptions` type
375+
376+
This type is used in the `scalars` option. It allows you to specify different `GeneratorOptions` for `input` and `output` types for
377+
your scalars, in the same way the [typescript-operations](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations#scalars) plugin does.
378+
379+
So, using the first example of the previous section, you can specify a `string` for your input and a `Date` for your `output`:
380+
381+
```yaml
382+
plugins:
383+
- typescript-mock-data:
384+
scalars:
385+
Date:
386+
input: date.weekday # Date fields in input objects will be mocked as strings
387+
output:
388+
generator: date.past # Date fields in other GraphQL types will be mocked as JS Dates
389+
arguments: 10
390+
```
391+
374392
## Examples of usage
375393

376394
**codegen.yml**

0 commit comments

Comments
 (0)