From 789c9c6234d2a71c0bfa2d3f028ad131f039bb54 Mon Sep 17 00:00:00 2001 From: Joao Garin Date: Sun, 7 Jan 2018 17:59:33 +0000 Subject: [PATCH] initial commit --- graphql_custom_mutations.info.yml | 7 ++ readme.md | 116 ++++++++++++++++++ src/Plugin/GraphQL/InputTypes/ClientInput.php | 21 ++++ src/Plugin/GraphQL/Mutations/AddClient.php | 39 ++++++ src/Plugin/GraphQL/Mutations/DeleteClient.php | 27 ++++ 5 files changed, 210 insertions(+) create mode 100755 graphql_custom_mutations.info.yml create mode 100755 readme.md create mode 100755 src/Plugin/GraphQL/InputTypes/ClientInput.php create mode 100755 src/Plugin/GraphQL/Mutations/AddClient.php create mode 100755 src/Plugin/GraphQL/Mutations/DeleteClient.php diff --git a/graphql_custom_mutations.info.yml b/graphql_custom_mutations.info.yml new file mode 100755 index 0000000..cf53a55 --- /dev/null +++ b/graphql_custom_mutations.info.yml @@ -0,0 +1,7 @@ +name: Custom graphql mutations +type: module +description: A collection of custom GraphQL Mutations +core: 8.x +package: Custom +dependencies: + - graphql diff --git a/readme.md b/readme.md new file mode 100755 index 0000000..0b7afed --- /dev/null +++ b/readme.md @@ -0,0 +1,116 @@ +A simple example of a basic page mutation + + + +ADD MUTATION +```$xslt +mutation { + addPage(input:{title:"Hello", body:"World"}){ + entity{ + ...on NodePage { + nid + title + body{ + value + } + } + } + } +} + +``` + +RESULT + +```$xslt +{ + "data": { + "addPage": { + "entity": { + "nid": 111, + "title": "Hello", + "body": { + "value": "World" + } + } + } + } +} +``` + + +--- + + +UPDATE MUTATION + +```$xslt +mutation { + updatePage(id:110, input:{title:"Justin"}){ + entity{ + ...on NodePage { + nid + title + body{ + value + } + } + } + } +} +``` + + +RESULT +```$xslt +{ + "data": { + "updatePage": { + "entity": { + "nid": 111, + "title": "Justin", + "body": null + } + } + } +} +``` + + +--- + + +DELETE MUTATION +```$xslt +mutation { + deletePage(id:111){ + entity{ + ...on NodePage { + nid + title + body{ + value + } + } + } + } +} + +``` + + +RESULT + +```$xslt +{ + "data": { + "deletePage": { + "entity": { + "nid": 111, + "title": "Justin", + "body": null + } + } + } +} +``` \ No newline at end of file diff --git a/src/Plugin/GraphQL/InputTypes/ClientInput.php b/src/Plugin/GraphQL/InputTypes/ClientInput.php new file mode 100755 index 0000000..1d77ca9 --- /dev/null +++ b/src/Plugin/GraphQL/InputTypes/ClientInput.php @@ -0,0 +1,21 @@ + $inputArgs['title'], + 'email' => $inputArgs['email'] + ]; + } +} \ No newline at end of file diff --git a/src/Plugin/GraphQL/Mutations/DeleteClient.php b/src/Plugin/GraphQL/Mutations/DeleteClient.php new file mode 100755 index 0000000..ad9722f --- /dev/null +++ b/src/Plugin/GraphQL/Mutations/DeleteClient.php @@ -0,0 +1,27 @@ +