Mutations
Learn how to use mutations in Sofa, which transform into POST requests and require body-parser.json() middleware or URL parameters. #GraphQL
Mutations are transformed into POST requests.
Given the following example:
Sofa will create a POST /add-comment route that accepts a { text } body.
For mutations to properly work with JSON bodies, you will need to have bodyParser.json() or a similar module as a middleware, else you will have to pass arguments via url paramaters.
Heres an example of without body-parser:
Will mean that you will have to access it like this:
How to enable body-parser:
Then you can simply initialise it like this: