Is there yet a way to use prisma generated inputs as input types for graphql? For example I have a user in datamodel.prisma like so:
type User {
id: ID! @unique
name: String!
email: String! @unique
password: String!
resetToken: String
resetTokenExpiry: Float
createdAt: DateTime!
updatedAt: DateTime!
}
which prisma uses to generate a bunch of functions, and say I want to make an updateUser mutation with the prisma generated struct as the input in schema.graphql.
The struct:
type UserUpdateInput struct {
Name *string `json:"name,omitempty"`
Email *string `json:"email,omitempty"`
Password *string `json:"password,omitempty"`
ResetToken *string `json:"resetToken,omitempty"`
ResetTokenExpiry *float64 `json:"resetTokenExpiry,omitempty"`
}
At the moment I have to recreate the UserUpdateInput in schema.graphql which is fine since the User type is comprised of nothing but scalars, however for other types the inputs are other prisma generated input types, for example:
type ArticleUpdateInput struct {
Title *string `json:"title,omitempty"`
Body *ArticleBodyUpdateOneWithoutArticleInput `json:"body,omitempty"`
Author *AuthorUpdateManyWithoutArticlesInput `json:"author,omitempty"`
Source *SourceUpdateOneRequiredWithoutArticlesInput `json:"source,omitempty"`
Url *UrlUpdateOneRequiredInput `json:"url,omitempty"`
Entities *EntityUpdateManyWithoutArticlesInput `json:"entities,omitempty"`
Sentiment *float64 `json:"sentiment,omitempty"`
PublishedAt *int32 `json:"publishedAt,omitempty"`
}
Is there a way around redefining every input type I want to use in schema.graphql?
So what you're really asking is if there is a way to somehow generate GraphQL input types from your Go types? Currently there isn't, but it could potentially be implemented as a plugin; a sort-of reverse schema-gen. gqlgen is primarily schema-first though, so I don't see this feature being implemented in the core, but it could be a contrib feature.
I'm very interested in this
Me too. Any plans on making this happen? I can help contribute if necessary.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
I'm very interested in this