Creating GraphQL field resolvers for specific types in Orionjs
@ModelResolvers()
that specifies the GraphQL type to extend, and contains methods decorated with @ModelResolver()
to define fields on that type:
@ModelResolvers()
decorator takes the schema that represents your GraphQL type. Each method decorated with @ModelResolver()
adds a new field to that type.
params
, this will be the parameters passed to the field@ModelResolver()
decorator accepts options to customize the field:
Option | Type | Description |
---|---|---|
name | string | Custom name for the GraphQL field (defaults to method name) |
description | string | Description for the field in GraphQL schema documentation |
returns
property of createModelResolver
:
@UseMiddleware()
:
@ModelResolvers()
decorator uses the class name of the provided schema. You can specify a custom name: