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

Commit

Permalink
magento/devdocs#: Resolvers. Add a tip about input/output types (#4331)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
atwixfirster authored and keharper committed Jun 25, 2019
1 parent 16a741e commit a30fd8c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions guides/v2.3/graphql/develop/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ Syntax option | Description
`@doc(description)` | Describes the purpose of the mutation
`@deprecated(reason: "description")` | Use `@deprecated` to mark a query, mutation, or attribute as deprecated

{:.bs-callout .bs-callout-tip}
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.

#### Example

**Wrong approach**

```text
type Mutation {
mutationQueryName(param1: String, param2: Int, ...): MutationQueryOutput @resolver(class: "Magento\\<module_name>\\Model\\Resolver\\MutationResolverModel") @doc(description:"Mutation query description")
}
```

**Correct approach**

```text
type Mutation {
mutationQueryName(inputParam: InputParamsType): MutationQueryOutput @resolver(class: "Magento\\<module_name>\\Model\\Resolver\\MutationResolverModel") @doc(description:"Mutation query description")
}
type InputParamsType {
param1: String
param2: Int
}
```

### Resolver class
Use the following sample code as a template for the GraphQl resolver query/mutation class

Expand Down

0 comments on commit a30fd8c

Please sign in to comment.