-
Notifications
You must be signed in to change notification settings - Fork 54
Automatically generate missing model definitions #181
Comments
Could you provide some more clarifying information please:
|
Yeah I mean exactly that what is generated in the CLI. And you were right, I was not aware of this behavior. First of all schema.graphql type AuthPayload {
token: String!
user: User!
} Generated model export interface AuthPayload {
token: string
user: any
} My suggestion would be to just put them into the |
I agree with @sapkra that definining the I mean actually if you forget to do it yourself, I think there is a way to make # src/schema.graphql
type AuthPayload {
token: String!
user: User!
} generated into // src/generated/graphqlgen.ts
export interface AuthPayload {
token: string
user: UserNode
} Then all already generated references to I'm not sure about the |
@schickling Issue was referenced in #237 but I didn't clearly understand how is it related, and is there any thoughts about what me and @sapkra wrote ? |
because of this comment: #237 (comment) |
@schickling Any updates on this ? Without automatically generating these models It's gonna be a pain for big projects to maintain both the Schema Exemple : Auto generate type Test {
a: String
b: String!
c: Int
d: Int!
} into export interface Test {
a?: string
b: string
c?: number
c: number
} If it's not auto-generated, As @sapkra already suggested =>
|
I would also like to have the types being auto generated, I don't see a point in having to maintain those manually. For example, I've been experimenting with using |
I have literally the exact same use case, would be nice if this could be auto-generated |
@schickling Any thoughts ? |
Is the Payload pattern not used by the Prisma team? I'm curious about how they structure input and output types for their mutations. The idea here is to create objects for all inputs and outputs which makes them more maintainable in the future, since clients do not need to worry about getting all the arguments in their correct order, and it seems easier to maintain backward compatibility? There is a medium article somewhere about it... There is quite a lot of boilerplate currently for this pattern as seen below. Is the recommendation simply not to use this pattern? Or is there another way of simplifying? @nikolasburk @divyenduz any thoughts? schema.graphql: (ideally this would be all you need to write?)
types.ts:
resolvers/AddNotePayload.ts:
resolvers/index.ts:
|
I think the use for auto generated models really depends on the project. |
Need to decide:
|
Description
I got some problems with missing types & had to fixed them by defining them by myself.
I think an easier solution would be to genereate them automatically from the types defined in
schema.graphql
Additional context
More information in my old ticket #163.
The text was updated successfully, but these errors were encountered: