Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit a30fd8c

Browse files
atwixfirsterkeharper
authored andcommitted
magento/devdocs#: Resolvers. Add a tip about input/output types (#4331)
* magento/devdocs#: Resolvers. Add a tip about input/output types * magento/devdocs#: Resolvers. Add a tip about input/output types * magento/devdocs#: Resolvers. Add a tip about input/output types
1 parent 16a741e commit a30fd8c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

guides/v2.3/graphql/develop/resolvers.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,32 @@ Syntax option | Description
6969
`@doc(description)` | Describes the purpose of the mutation
7070
`@deprecated(reason: "description")` | Use `@deprecated` to mark a query, mutation, or attribute as deprecated
7171

72+
{:.bs-callout .bs-callout-tip}
73+
It is a good practice to define separate types for input and output data. This practice permits additional extension points, so every input and output type can be extended by adding additional fields to the definition.
74+
75+
#### Example
76+
77+
**Wrong approach**
78+
79+
```text
80+
type Mutation {
81+
mutationQueryName(param1: String, param2: Int, ...): MutationQueryOutput @resolver(class: "Magento\\<module_name>\\Model\\Resolver\\MutationResolverModel") @doc(description:"Mutation query description")
82+
}
83+
```
84+
85+
**Correct approach**
86+
87+
```text
88+
type Mutation {
89+
mutationQueryName(inputParam: InputParamsType): MutationQueryOutput @resolver(class: "Magento\\<module_name>\\Model\\Resolver\\MutationResolverModel") @doc(description:"Mutation query description")
90+
}
91+
92+
type InputParamsType {
93+
param1: String
94+
param2: Int
95+
}
96+
```
97+
7298
### Resolver class
7399
Use the following sample code as a template for the GraphQl resolver query/mutation class
74100

0 commit comments

Comments
 (0)