You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @Code-Hex ! Thanks for this plug-in. It's helping us out quite a bit in preventing human errors in our application.
I was looking into the withObjectType but was facing some problems. The option generates models beautifully, but it generates the schemas to contain the entire model based on the introspected graphql model, instead of the one we've been requesting through our query (which might just be intentional).
The entire something.details, contains more properties. Mostly information that we don't want to query, and don't need in our object schemas. Let's say the entire something model looks like this:
While this is technically correct in a sense that the properties in theory do exist, our query never contained the 'height' and 'width' properties, leaving us with a schema that doesn't actually match the actual data flowing through our application.
The data is set to nullish(), which is great in a way that you can still use the schema to parse data, however - we also use the schemas with our DTO solution, which takes Zod schemas and uses them to parse incoming/outgoing data and generates OpenAPI specs for our endpoints: https://github.com/risen228/nestjs-zod - the problem we face with this, is that the generated schema will suggest there will be more properties than we would actually have.
I think my question comes down to: Is it intentional that withObjectTypes contains all of the available properties on a graphql model, and if so - shouldn't there be an option to only generate schemas with the requested properties based on the query ?
Happy to think with you on this one, sorry if it has been asked before :)
The text was updated successfully, but these errors were encountered:
Hey @Code-Hex ! Thanks for this plug-in. It's helping us out quite a bit in preventing human errors in our application.
I was looking into the
withObjectType
but was facing some problems. The option generates models beautifully, but it generates the schemas to contain the entire model based on the introspected graphql model, instead of the one we've been requesting through our query (which might just be intentional).For example, our query looks like this:
The entire
something.details
, contains more properties. Mostly information that we don't want to query, and don't need in our object schemas. Let's say the entiresomething
model looks like this:The output model schema now gets returned to us as:
While this is technically correct in a sense that the properties in theory do exist, our query never contained the 'height' and 'width' properties, leaving us with a schema that doesn't actually match the actual data flowing through our application.
The data is set to
nullish()
, which is great in a way that you can still use the schema to parse data, however - we also use the schemas with our DTO solution, which takes Zod schemas and uses them to parse incoming/outgoing data and generates OpenAPI specs for our endpoints: https://github.com/risen228/nestjs-zod - the problem we face with this, is that the generated schema will suggest there will be more properties than we would actually have.I think my question comes down to: Is it intentional that
withObjectTypes
contains all of the available properties on a graphql model, and if so - shouldn't there be an option to only generate schemas with the requested properties based on thequery
?Happy to think with you on this one, sorry if it has been asked before :)
The text was updated successfully, but these errors were encountered: