Definition
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
context | connect__FieldSet! | — | A space-separated list of sibling fields from the parent type to pass as resolver context. |
Overview
@connect__fieldResolver is part of the Cosmo Connect gRPC integration.
It marks a field so that the router resolves it through a separate RPC call
instead of including it in the parent type’s response.
Without this directive,
all fields on a type are resolved together in a single RPC call.
This is efficient when every field comes from the same data source,
but not when some fields are expensive to compute or served by a different backend.
For example,
id and price on a Product type might come from a local database,
while shippingEstimate requires a call to an external shipping service
with higher latency.
By annotating shippingEstimate with @connect__fieldResolver,
the router only calls the shipping service when the client actually requests that field.
The context argument specifies which fields from the parent type the resolver needs.
These fields are fetched first,
then passed to a generated Resolve{TypeName}{FieldName} RPC method.
The router batches all context entries into a single call using a repeated message,
eliminating N+1 problems.
For a complete guide including protobuf generation,
Go implementation examples,
and batching behavior,
see Field Resolvers.
Example
id and price from the parent RPC.
It then calls ResolveProductShippingEstimate with those values as context
and zip as a field argument.
Generated protobuf
For theshippingEstimate field in the example above,
the protographic tooling generates:
context message contains the fields listed in the directive (id and price).
Because the field has a GraphQL argument (zip),
an Args message and field_args field are added to the request.
See also
- Field Resolvers guide for implementation details and batching behavior.
@requiresfor declaring cross-subgraph field dependencies.- Cosmo Connect for the full gRPC integration overview.