Last active
March 27, 2017 06:48
-
-
Save bbuck/74cb8446cdb49bf8ac22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation _ { | |
newTodo: createTodo(text: "This is a todo mutation example") { | |
text | |
done | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// more code | |
mutationType := graphql.NewObject(graphql.ObjectConfig{ | |
Name: "TodoMutations", | |
Fields: graphql.Fields{ | |
"createTodo": &graphql.Field{ | |
Type: todoType, | |
Args: graphql.FieldConfigArgument{ | |
"text": &graphql.ArgumentConfig{ | |
Type: graphql.NewNonNull(graphql.String), | |
}, | |
}, | |
Resolve: func(params graphql.ResolveParams) (interface{}, error) { | |
text := params.Args["text"].(string) | |
todo := data.NewTodo(text) | |
todo.Save() | |
return todo, nil | |
}, | |
}, | |
}, | |
}) | |
schema, err := graphql.NewSchema(graphql.SchemaConfig{ | |
Query: queryType, | |
Mutation: mutationType, | |
}) | |
// more codeL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"newTodo": { | |
"text": "This is a todo mutation example", | |
"done": false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment