-
Notifications
You must be signed in to change notification settings - Fork 54
Make createUser name argument default null #397
Conversation
Hey @nunovieira thanks for this! It looks like our improved type generation in 0.5.0 is catching subtle type errors previously latent. We ought to have a test suite for avoiding breaking the templates again in the future like that. You're fix is certainly reasonable but there are alternatives to changing the model types, such as: diff --git a/src/schema.graphql b/src/schema.graphql
index 31321e1..ca6e4d8 100644
--- a/src/schema.graphql
+++ b/src/schema.graphql
@@ -5,7 +5,7 @@ type Query {
}
type Mutation {
- createUser(name: String): User!
+ createUser(name: String = null): User!
createDraft(title: String!, content: String!, authorId: ID!): Post!
deletePost(id: ID!): Post
publish(id: ID!): Post diff --git a/src/resolvers/Mutation.ts b/src/resolvers/Mutation.ts
index a66005f..b0bc1f9 100644
--- a/src/resolvers/Mutation.ts
+++ b/src/resolvers/Mutation.ts
@@ -1,7 +1,7 @@
import { MutationResolvers } from '../generated/graphqlgen'
export const Mutation: MutationResolvers.Type = {
- createUser: (parent, { name }, ctx) => {
+ createUser: (parent, { name = null }, ctx) => {
const id = ctx.data.idProvider()
const newUser = { id, name, postIDs: [] }
ctx.data.users.push(newUser) I think using |
I didn't knew that feature! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nunovieira agree lets update both templates. Can you make those changes using the aforementioned GraphQL SDL null-default feature, thanks!
This is the simplest fix for prisma-labs#396 I came up with. But maybe `name` should be required, as in `flow-yoga` template?
I've amended the commit with your suggestion.
I'm not that comfortable with flow to make that change. |
This is the simplest fix for #396 I came up with.
But maybe
name
should be required, as inflow-yoga
template?