Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Organising large number of mutations

Tags:

graphql

We have an established system which does not have a public API and we're evaluating GraphQL as a possible solution. We have a dozen or so different types, relations and possible actions/mutations.

From what we have read and from our experimentation's we can only have a single root node and all the mutations have to be listed here. We have many modules each with many entities and many actions available on each.

How are people organising large numbers of mutations? We're struggling to find examples of large applications using GraphQL that we can learn from.

like image 549
Iain Mckay Avatar asked Sep 16 '16 16:09

Iain Mckay


1 Answers

Recently, I struggled with a similiar problem. I tried to organize my mutations in more nested way. The idea was to have something like this:

mutation {
    users { 
        addUser(name: "Foo")
            id
        }
    }
}

Unfortunately, this can't be done, therefore you should put all your mutations on Root mutation level.

The whole problem is discussed here https://github.com/graphql/graphql-js/issues/221

where @LeeByron explains

We do not support mutations at any level other than the top.

like image 134
LordDave Avatar answered Nov 14 '22 21:11

LordDave