hello_graphql_phoenix
hello_graphql_phoenix copied to clipboard
Add mutation examples
It would be nice to have some examples of changing data through graphql mutations.
Yes absolutely. This is definitely missing and we'll add these in this week.
@joshprice thank you. While I got the general idea from looking at the code itself and examples for other languages, I think it would benefit anyone who explores the GraphQL through this example repo to be able to see the examples for mutations, clone them to their machine and play around to see how do they work.
It's definitely our top priority, thanks for the bug report. 🙏
Is there an update on the progress of these code examples?
Has anybody come across any mutation examples in external repos?
@0x6e6562 there are some examples in repos from official GraphQL Github organization.
- The
graphql-js
has multiple mentions of them - The
express-graphql
has one example definition of empty mutation
The graphql-relay-js
repo has multiple mentions too.
Also, here is the post on Medium about mutations: https://medium.com/@tarkus/validation-and-user-errors-in-graphql-mutations-39ca79cd00bf
The docs from graphql-relay-ruby
also mention mutations
Quote (empathis mine):
Mutations allow Relay to mutate your system. They conform to a strict API which makes them predictable to the client. ... Members of MutationType are mutation fields. For GraphQL in general, mutation fields are identical to query fields except that they have side-effects (which mutate application state, eg, update the database). For Relay-compliant GraphQL, a mutation field must comply to a strict API. GraphQL::Relay includes a mutation definition helper (see below) to make it simple.
So, there are 1) regular GraphQL mutations, which are queries that have side-effects like modifying the database and 2) Relay mutations that are somehow stricter in terms of API.
I'm also wondering how to handle file uploads. Sending file using relay getFiles()
, but I don't have access to the param holding the file upload.
Seeing no info here in regards to %Plug.Upload
https://github.com/graphql-elixir/graphql/blob/master/lib/graphql/execution/executor.ex#L141