Ra Ka
Ra Ka

Reputation: 3055

How to perform Mutation in sangria-graphql?

Currently, I'm learning sangria-graphql from here. However, I could not find any documentation for Mutation (Add, Update, Delete). Also, google won't help me much. So, can you guys provide me with any good resources?

Upvotes: 2

Views: 1510

Answers (1)

tenshi
tenshi

Reputation: 26566

Mutations in GraphQL are modeled as an object type, just like the Query type. GraphQL schema has 3 top-level entry points which are modeled as object types:

  • Query type - the root for the queries
  • Mutation type - the root for the mutations
  • Subscription type - the root for the subscriptions

When you created the scheme, you can provide all 3 of them:

Schema(QueryType, Some(MutationType), Some(SubscriptionType))

Otherwise, mutations work very similar to queries, except that the mutation top-level fields are executed sequentially (guaranteed not to execute in parallel).

For further info and examples, I would recommend you to check sangria-subscriptions-example which demonstrates mutation and subscriptions in addition to normal queries. I would suggest you to start at schema definition:

https://github.com/sangria-graphql/sangria-subscriptions-example/blob/master/src/main/scala/schema.scala#L87

Upvotes: 6

Related Questions