Skip to main content

utility

delegate Resolver​

A resolver which delegates to another query, mutation, or property. This enables complex resolver mappings to be reused throughout the schema while maintaining a DRYer schema.


name​

Type​

string!

Values​

  • delegate

to​

Type​

string!

Description​

A reference to a property, query, or mutation to delegate to. For example Query.getPostList or stripe:Query.listProducts.


args​

Type​

ParameterConfig?


results​

Type​

ParameterConfig?



options​

Type​

object

Option Descriptions​

selectionSet​

Optional string. When delegating to a GraphQL query, the default behavior is to use the same selection set for the delegated query as was provided to the delegate resolver. If the delegate resolver's return Shape is not the same as the to query return Shape, specifying selectionSet will be necessary.

For example, let's start with this query:

character(id:"123") {
name
episode {
name
air_date
}
}

What if you wanted to make a query that gets the first episode a character appeared in? You could achieve that with a delegate resolver like this one.

"getFirstCharacterEpisode": {
"shape": "Rick_Episode",
"args": {
"type": "object",
"properties": {"characterId": {"type": "string"}}
},
"resolver": {
"name": "delegate",
"to": "rick:Query.character",
"args": {"ops": [{"path": "id", "mapping": "$args.characterId"}]},
"results": {
"ops": [{"path": "$", "mapping": "$finalResolver.episode[0]"}]
},
"options": {
"selectionSet": "{episode {..._parentFragment}}",
"unboxParentSelectionSet": false
}
}
}

You could then write a query like this:

{
getFirstCharacterEpisode(characterId: "123") {
name
air_date
}
}
unboxParentSelectionSet​

Same behavior as the option with the same name in the GraphQL resolver.


Misc Resolvers​

Some simple utilities. Mostly for internal use and debugging.


name​

Type​

string!

Values​

  • util:noop
  • util:wrap