graphql-compose-mongoose icon indicating copy to clipboard operation
graphql-compose-mongoose copied to clipboard

InputTypes generated for Discriminators

Open MatthewJonD opened this issue 4 years ago • 3 comments

May have missed the options.... But, for example, in using the CreateOne*Input type for the createOne resolver, the discriminatorKey field isnt included in the generated type.

So for the documentation example- CharacterSchema.set('discriminatorKey', 'type'); The type field is not included in the CreateOneDroidInput Is it possible to include it for the inputType?

MatthewJonD avatar Apr 26 '21 00:04 MatthewJonD

You may add it manually:

CreateOneResolver.getArgITC('record').setField('type', 'String!');

graphql-compose allows modifying all generated types as you wish. Anyway, feel free to write your custom resolver if you met with a complex situation uncovered by a generator (composeMongoose()).

nodkz avatar May 05 '21 21:05 nodkz

Thanks. Will do.

BTW- What was the thinking for not including? Just wondering if Im my implementation is crazy

MatthewJonD avatar May 15 '21 12:05 MatthewJonD

Yep, it can be added but need to think about how it can be implemented. CharacterSchema.set('discriminatorKey', 'type'); added to mongoose schema without any hint about what exactly type is used for this field (string, int, float).

It will be nice if you have time to open Pull Request and propose your solution.

nodkz avatar May 16 '21 18:05 nodkz