-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
Description
The newly implemented defaultNullableToNull option should take precedence over custom Scalar definitions as you cannot define those optionally and are global.
As implemented in #130 it makes sense for specific field configuration to take precedence over defaultNullableToNull.
Precedence of options should be fieldGeneration > defaultNullableToNull > scalars.
If folks agree I'm happy to give this a crack in the coming days.
Example GQL Schema
type Hat {
id: ID!
description?: String
}Example config
src/__generated__/test-fixtures.gql.ts:
plugins:
- add:
content: "import { faker } from '@faker-js/faker';"
- typescript-mock-data:
typesFile: ./base.gql.ts
defaultNullableToNull: true
scalars:
ID: faker.string.uuid()
String: faker.word.words()
Boolean: faker.datatype.boolean()Current output
export const aHat = (overrides?: Partial<Hat>): Hat => {
return {
id: overrides && overrides.hasOwnProperty('id') ? overrides.apiKeyName! : faker.string.uuid(),
description: overrides && overrides.hasOwnProperty('description') ? overrides.apiKeyName! : faker.word.words(),
}
}Expected output
export const aHat = (overrides?: Partial<Hat>): Hat => {
return {
id: overrides && overrides.hasOwnProperty('id') ? overrides.apiKeyName! : faker.string.uuid(),
description: overrides && overrides.hasOwnProperty('description') ? overrides.apiKeyName! : null,
}
}