-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Describe the bug
input Option @oneOf {
field: String
}
input Options {
option: Option
}
Since #180, the generation for the Option
type (which itself has the @oneOf
directive) works correctly. However, generation for the Options
type (which does not have the @oneOf
directive, but has a field who's type does) produces incorrect code with type errors when the terminateCircularRelationships: 'immediate'
option is used.
What it produces is something like this:
export const anOptionsInput = (overrides?: Partial<OptionsInput>, _relationshipsToOmit: Set<string> = new Set()): OptionsInput=> {
const relationshipsToOmit: Set<string> = _relationshipsToOmit;
relationshipsToOmit.add('OptionsInput');
return {
option: overrides && overrides.hasOwnProperty('option') ? overrides.option! : relationshipsToOmit.has('Option') ? {} as Option: anOption({}, relationshipsToOmit),
};
};
anOption({}, relationshipsToOmit)
produces a type error, because Option
requires one of it's fields to be set. At although {} as Option
doesn't produce a type error because of the cast, it is incorrect for the same reason.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
terminateCircularRelationships: 'immediate'
, schema as in description. Note that generated code has type errors.
Expected behavior
No type errors, correct code.
Screenshots or Videos
No response
Platform
graphql-codegen-typescript-mock-data
version(s): [e.g. 5.0.1]
Codegen Config File
terminateCircularRelationships: 'immediate'
Additional context
No response