hello_graphql_phoenix icon indicating copy to clipboard operation
hello_graphql_phoenix copied to clipboard

Add mutation examples

Open ivan-kolmychek opened this issue 9 years ago • 10 comments

It would be nice to have some examples of changing data through graphql mutations.

ivan-kolmychek avatar Feb 04 '16 15:02 ivan-kolmychek

Yes absolutely. This is definitely missing and we'll add these in this week.

joshprice avatar Feb 14 '16 21:02 joshprice

@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.

ivan-kolmychek avatar Feb 15 '16 12:02 ivan-kolmychek

It's definitely our top priority, thanks for the bug report. 🙏

joshprice avatar Feb 15 '16 13:02 joshprice

Is there an update on the progress of these code examples?

mechabyte avatar Mar 15 '16 16:03 mechabyte

Has anybody come across any mutation examples in external repos?

0x6e6562 avatar Apr 19 '16 16:04 0x6e6562

@0x6e6562 there are some examples in repos from official GraphQL Github organization.

ivan-kolmychek avatar Jul 14 '16 14:07 ivan-kolmychek

The graphql-relay-js repo has multiple mentions too.

ivan-kolmychek avatar Jul 14 '16 14:07 ivan-kolmychek

Also, here is the post on Medium about mutations: https://medium.com/@tarkus/validation-and-user-errors-in-graphql-mutations-39ca79cd00bf

ivan-kolmychek avatar Jul 14 '16 14:07 ivan-kolmychek

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.

ivan-kolmychek avatar Jul 20 '16 11:07 ivan-kolmychek

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

kespinola avatar Aug 02 '16 04:08 kespinola