-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TODO: A simple mutation example #60
Comments
I've re-written @bbuck's original example here: |
This is another version of the above example, but using https://gist.github.com/sogko/7debd336118e5e7c7f65 How to make GraphQL HTTP request using cUrlIn So given the following query: mutation M {
newTodo: createTodo(text: "This is a todo mutation example") {
text
done
}
} using GET$ curl -g -GET 'http://localhost:8080/graphql?query=mutation+M{newTodo:createTodo(text:"This+is+a+todo+mutation+example"){text+done}}' using POST + Content-Type: application/graphql$ curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/graphql' -d 'mutation M { newTodo: createTodo(text: "This is a todo mutation example") { text done } }' using POST + Content-Type: application/json$ curl -XPOST http://localhost:8080/graphql -H 'Content-Type: application/json' -d '{"query": "mutation M { newTodo: createTodo(text: \"This is a todo mutation example\") { text done } }"}' Any of the above would return the same output: {
"data": {
"newTodo": {
"done": false,
"text": "This is a todo mutation example"
}
}
} |
Thanks @sogko! |
Also helpful to note, if there are "optional" params that you don't send in the query you'll have an issue trying to convert
Prevents panicking. If I'm correct, it will default optionVal to the nil for string. |
Oops, thanks for catching that @EmergentBehavior 👍🏻 |
Adds the simple mutation for graphql-go#60 Left to do: [ ] add an http based example
Adding an http example for graphql-go#60 Left to do: - [ ] clean up the schema so its only in one place
Adding an http example for #60 Left to do: - [ ] clean up the schema so its only in one place
Adds the simple mutation for #60 Left to do: [ ] add an http based example
With PR #21 and PR #59, we now have two basic examples that would benefit new users:
Hello World
(query)Several people had asked for a working example of a mutation query, using purely GraphQL, (i.e. without Relay).
Currently the only example floating around is written by @bbuck in his gist here; albeit using the old API:
https://gist.github.com/bbuck/74cb8446cdb49bf8ac22
Putting this out there to invite anyone to contribute! 👍🏻
Update: For #46 , I've added a mutation example there to address the question. May not be the best example for introduce someone to mutations, though.
The text was updated successfully, but these errors were encountered: