From 2ca883ca2122af46cdbc16ac1d3064977c77f0c4 Mon Sep 17 00:00:00 2001 From: Will G Date: Mon, 13 Nov 2023 13:00:26 -0500 Subject: [PATCH 1/2] Create NamespacedDirective.php Create a "@namespaced" directive; ISO #2266 --- src/Schema/Directives/NamespacedDirective.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Schema/Directives/NamespacedDirective.php diff --git a/src/Schema/Directives/NamespacedDirective.php b/src/Schema/Directives/NamespacedDirective.php new file mode 100644 index 000000000..159b7a335 --- /dev/null +++ b/src/Schema/Directives/NamespacedDirective.php @@ -0,0 +1,25 @@ + true; + } +} From ec68eed5b3684f803d0e605e619947704c7c6923 Mon Sep 17 00:00:00 2001 From: Will G Date: Mon, 13 Nov 2023 13:11:38 -0500 Subject: [PATCH 2/2] Update directives.md Update Docs --- docs/master/api-reference/directives.md | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/master/api-reference/directives.md b/docs/master/api-reference/directives.md index ee1fd019f..15fe2d2d9 100644 --- a/docs/master/api-reference/directives.md +++ b/docs/master/api-reference/directives.md @@ -2279,6 +2279,51 @@ extend type Query @namespace(field: "App\\Blog") { A [@namespace](#namespace) directive defined on a field directive wins in case of a conflict. +## @namespaced + +```graphql +""" +A no-op nested field resolver that allows nesting of queries and mutations. +""" +directive @namespaced on FIELD_DEFINITION +``` + +The following example shows how one can namespace queries and mutations. + +```graphql +type Query { + posts: PostQueries! @namespaced +} + +type PostQueries { + single( + id: ID @eq + ): Post! @find + + list( + title: String @where(operator: "like") + ): [Post!]! @paginate(defaultCount: 10) +} + +type Mutation { + posts: PostMutations! @namespaced +} + +type PostMutations { + create( + input: PostCreateInput @spread + ): Post! @create + + update( + input: PostUpdateInput @spread + ): Post! @update + + delete( + id: ID! @whereKey + ): Post @delete +} +``` + ## @neq ```graphql