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

magento/devdocs#: Resolvers. Add a tip about input/output types #4331

Merged
merged 7 commits into from
Jun 25, 2019
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 @@ -68,6 +68,32 @@ Syntax option | Description
`@resolver(class)` | The class of the resolver
`@doc(description)` | Describes the purpose of the mutation

{:.bs-callout .bs-callout-tip}
It's a good practice to define a separate types for input/output data. It bring additional extension points, so every input/output type can be extended by adding additional fields to the definition.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It's a good practice to define a separate types for input/output data. It bring additional extension points, so every input/output type can be extended by adding additional fields to the definition.
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Thank you, @keharper 👍


#### 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