Skip to content

Commit c3a2a57

Browse files
authored
Updated README with a mutation example.
1 parent 96a85b8 commit c3a2a57

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,31 @@ query NewName ($variable1: String!, $variableWithDefault: String = "default_valu
489489
title
490490
}
491491
}
492+
493+
```
494+
### Mutation example
495+
496+
```typescript
497+
import { jsonToGraphQLQuery, VariableType } from 'json-to-graphql-query';
498+
499+
const mutation = {
500+
mutation: {
501+
delete_post: {
502+
__args: { id: 1234 },
503+
id: true,
504+
}
505+
}
506+
};
507+
const graphql_query = jsonToGraphQLQuery(mutation, { pretty: true });
508+
```
509+
510+
Resulting `graphql_query`
511+
```graphql
512+
mutation {
513+
delete_post (id: 1234) {
514+
id
515+
}
516+
}
492517
```
493518

494519
## TO-DO List

0 commit comments

Comments
 (0)