GraphQLResolverMap
GraphQLResolverMap API reference.
Proto: graphql_resolver_map.proto
Package: apimanagement.gloo.solo.io
Types:
- DynamicMetadataExtraction
- Extraction
- GraphQLResolverMapReport
- GraphQLResolverMapReport.WorkspacesEntry
- GraphQLResolverMapSpec
- GraphQLResolverMapSpec.Resolution
- GraphQLResolverMapSpec.Resolution.FieldsEntry
- GraphQLResolverMapSpec.Resolution.Resolvers
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate.RequestMetadataEntry
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver.AsyncResponse
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RESTVariable
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.HeadersEntry
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.QueryParamsEntry
- GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.VariablesEntry
- GraphQLResolverMapSpec.Resolution.Resolvers.VariablesEntry
- GraphQLResolverMapSpec.ResolverMapExtensions
- GraphQLResolverMapSpec.TypesEntry
- GraphQLResolverMapStatus
- VariableTransformation
DynamicMetadataExtraction
Field | Description |
---|---|
metadataNamespace | (string )The envoy dynamic metadata namespace that the data lives in. If the namespace doesn’t exist in the metadata, the extraction yields null |
key | (string )The key under the envoy dynamic metadata namespace that the data lives under. If the key doesn’t exist in the namespace, the extraction yields null |
Extraction
Extractions are used to assign values to variables from various sources of data in the GraphQL request or response. This includes HTTP headers, Envoy Dynamic Metadata, or GraphQL query-specific args.
Field | Description |
---|---|
requestHeader | (string )Extract the value from the GraphQL HTTP request header. The extracted value is a string. If the header doesn’t exist, an empty string will be used. |
dynamicMetadata | (DynamicMetadataExtraction )Extract the value from envoy dynamic metadata. The extracted value is an object. |
graphqlParent | (google.protobuf.Empty )Assigns the variable to the parent object For information about the value format, see the Google protocol buffer documentation. |
graphqlArg | (string )Assigns the variable to the GraphQL Argument with this name. If this name doesn’t exist, the variable is null |
resolverResult | (google.protobuf.Empty )Assigns the variable to the GraphQL resolver result. If this Extraction is used in a place where the resolver result is not available, an error will be thrown during configuration time. For information about the value format, see the Google protocol buffer documentation. |
json | (google.protobuf.Value )Assigns the variable to a JSON value specified here For information about the value format, see the Google protocol buffer documentation. |
GraphQLResolverMapReport
Field | Description |
---|---|
workspaces | (repeated GraphQLResolverMapReport.WorkspacesEntry ) |
ownerWorkspace | (string )The name of the workspace that owns the Graphql resolver map. |
GraphQLResolverMapReport.WorkspacesEntry
Field | Description |
---|---|
key | (string ) |
value | (common.gloo.solo.io.Report ) |
GraphQLResolverMapSpec
The GraphQLResolverMap Resource contains a mapping from types to fields to
resolutions. For example, for a schema with type Query
and field GetName
type Query {
GetName: String
}
you can configure a resolver for the GetName
field as follows:
types:
Query:
fields:
GetName:
<insert resolver config>
Field | Description |
---|---|
types | (repeated GraphQLResolverMapSpec.TypesEntry )Map of GraphQL types to field resolutions. The key must match the GraphQL type name and is case-sensitive. Every field under GraphQL root types (Query, Mutation) must have a resolver defined. |
extensions | (GraphQLResolverMapSpec.ResolverMapExtensions )Extensions that apply to the resolvers in this ResolverMap. |
GraphQLResolverMapSpec.Resolution
Field | Description |
---|---|
fields | (repeated GraphQLResolverMapSpec.Resolution.FieldsEntry )Map of GraphQL fields for the type to resolutions. The key must match the GraphQL field name and is case-sensitive. Fields that don’t have resolvers will use the GraphQL default resolver, which returns the field in the parent object with the same name as the GraphQL field. |
GraphQLResolverMapSpec.Resolution.FieldsEntry
Field | Description |
---|---|
key | (string ) |
value | (GraphQLResolverMapSpec.Resolution.Resolvers ) |
GraphQLResolverMapSpec.Resolution.Resolvers
Field | Description |
---|---|
resolvers | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.Resolver )List of resolvers. Currently, only one the first resolver configuration will be respected and a warning will be thrown if more than one resolver is in the list. |
variables | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.VariablesEntry )Variables that can be used as a part of transformations for this field’s resolution. The key is the name of the variable, which is directly used in the transformation. The value defines where the variable value is extracted from on the GraphQL request. |
statPrefix | (google.protobuf.StringValue )The stats prefix which will be used for this resolver. If empty, will generate a stats prefix ${RESOLVER_NAME} |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver
Field | Description |
---|---|
restResolver | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver )Resolves values by making a HTTP/2 request to a HTTP/REST destination. |
grpcResolver | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver )Resolves fields by making a gRPC call to a gRPC destination. |
mockResolver | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver )Resolves fields via a mocked response that is configured. |
resolverResultTransform | (VariableTransformation )Use a transformation on extracted variables to transform the upstream REST response. By default, the transformation is empty and the destination response is left as is before being passed into the GraphQL execution engine. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver
Field | Description |
---|---|
destinations | (repeated common.gloo.solo.io.DestinationReference )Required: list of destinations which point to destinations containing a gRPC service. Must provide at least one destination. (Note: only the first destination will be used) |
request | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate ) |
spanName | (google.protobuf.StringValue )The span name for the upstream gRPC request, used for tracing. If left empty or not set, the request span name will be set to the upstream cluster name. |
timeout | (google.protobuf.Duration )Set the timeout of the HTTP request to the gRPC service (default 5s) For information about the value format, see the Google protocol buffer documentation. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate
Field | Description |
---|---|
service | (string )The gRPC service to call. |
method | (string )The gRPC method to call. |
outgoingMessage | (VariableTransformation )The gRPC request body. The request body is a JSON object that will be marshalled into the gRPC request. The request body can be templated using variables from the variables field. |
requestMetadata | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate.RequestMetadataEntry )Static metadata to be added to the gRPC request. See https://grpc.io/docs/what-is-grpc/core-concepts/#metadata for more information. |
authority | (google.protobuf.StringValue )The :authority header to set on the gRPC request. If empty, the outgoing :authority header will be set to “envoy”. This does not need to be set in most cases. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.GrpcResolver.RequestTemplate.RequestMetadataEntry
Field | Description |
---|---|
key | (string ) |
value | (string ) |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver
Field | Description |
---|---|
syncResponse | (VariableTransformation )The response to return for this field. The response is a JSON object that can be templated from the variables field. This response is immediately returned to the GraphQL execution engine. |
asyncResponse | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver.AsyncResponse )The response to return for this field. The response is a JSON object that can be templated from the variables field. This response is returned to the GraphQL execution engine after a delay. |
errorResponse | (string )An error response to return for this field. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.MockResolver.AsyncResponse
Field | Description |
---|---|
delay | (google.protobuf.Duration )The delay before the response is returned. For information about the value format, see the Google protocol buffer documentation. |
response | (VariableTransformation )The response to return. The response is a JSON object that can be templated from the variables field. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver
Field | Description |
---|---|
destinations | (repeated common.gloo.solo.io.DestinationReference )Required: list of destinations which point to destinations containing a RESTful service. Must provide at least one destination. (Note: only the first destination will be used) |
request | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate )Configuration to template a HTTP request to fetch JSON from a destination REST service. This includes configuration such as setting headers dynamically on the HTTP request, configuring query_params, and setting the body for the request to the destination. |
variables | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.VariablesEntry )Variables that can be used in this field’s response transform. The key is the name of the variable, which is directly used in the transformation. The value defines where the variable value is extracted from on the GraphQL REST response. |
spanName | (google.protobuf.StringValue )The span name for the upstream REST request, used for tracing. If left empty or not set, the request span name will be set to the upstream cluster name. |
timeout | (google.protobuf.Duration )Set the timeout of the HTTP request to the REST service (default 5s) For information about the value format, see the Google protocol buffer documentation. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RESTVariable
Field | Description |
---|---|
responseHeader | (string )Only available on resolver result transformations Extract the value from the GraphQL HTTP response header. The extracted value is a string. If this Extraction is used in a place where response headers are not available, an error will be thrown during configuration time. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate
Field | Description |
---|---|
headers | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.HeadersEntry )Sets the headers on the request to the REST destination. This includes setting HTTP :path header. This is a map of HTTP Header name to a transformation which determines the Header value. The transformation must result in a string value, or an error will be sent back to the client. By default, the :method header is set to GET. If body is set, then the :method is POST. This can be overridden by setting the :method header manually below. |
queryParams | (repeated GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.QueryParamsEntry )Sets the query parameters on the request to the REST destination. The transformation must result in a string value, or an error will be sent back to the client. |
body | (VariableTransformation )Sets the outgoing body to the upstream REST destination. By default, the body is empty. |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.HeadersEntry
Field | Description |
---|---|
key | (string ) |
value | (VariableTransformation ) |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RequestTemplate.QueryParamsEntry
Field | Description |
---|---|
key | (string ) |
value | (VariableTransformation ) |
GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.VariablesEntry
Field | Description |
---|---|
key | (string ) |
value | (GraphQLResolverMapSpec.Resolution.Resolvers.Resolver.RestResolver.RESTVariable ) |
GraphQLResolverMapSpec.Resolution.Resolvers.VariablesEntry
Field | Description |
---|---|
key | (string ) |
value | (Extraction ) |
GraphQLResolverMapSpec.ResolverMapExtensions
Field | Description |
---|---|
grpcSchemaSelector | (common.gloo.solo.io.ObjectSelector )Selects API Schema objects that describe a gRPC service. This is used only in gRPC resolvers that are defined in this resolver map. The gRPC resolver uses the protobuf descriptor to create gRPC requests to the upstream gRPC service. Any non-gRPC API Schema that is selected here will be ignored. gRPC schemas will be checked for validity, as well as package/message conflicts at configuration time and will fail loudly if not valid. |
GraphQLResolverMapSpec.TypesEntry
Field | Description |
---|---|
key | (string ) |
value | (GraphQLResolverMapSpec.Resolution ) |
GraphQLResolverMapStatus
Field | Description |
---|---|
common | (common.gloo.solo.io.Status ) |
ownedByWorkspace | (string )The name of the workspace that owns the Graphql resolver map. |
VariableTransformation
Variable transformations are used to take variables that were declared
and transform them using a transformation. The simplest transformation is the variable
transform, which passes through the value of a single variable. For more complex transforms,
the jq
transformation can be used to form more complicated JSON values.
Using variables:
Variables that are declared in the variables
field are available at the top level of the input JSON object to the
jq filter.
For example, if the following variables have been declared:
variables:
userIdHeader:
request_header: x-user-id
resolverResultVar:
resolver_result: {}
then the input object to the jq
filter would be
{
"userIdHeader": <x-user-id header value from GraphQL request>,
"resolverResultVar": { .. the resolver result .. }
}
Using a jq filter:
Given the following input object to the jq
transformation, we can use a filter to transform the values.
{
"userIdHeader": "john_doe123",
"resolverResultVar": { "data": {"name": "John Doe"} }
}
If the jq
filter is defined as
"User: " + .userIdHeader + ", Name: " + .resolverResultVar.data.name
the result of the jq transformation would be
"User john_doe123, Name: John Doe"
Field | Description |
---|---|
variable | (string )The name of a variable declared in the variables field. The value of the variable is returned with no transformation. |
jq | (string )The jq filter which is used to provide a value. variables defined in variables can be used in the jq filter via regular jq variable syntax. For example, a variable named “userIdHeader” can be used in a jq filter as $userIdHeader Jq filters must only result in one value, or an error will be sent back to the client. For example, for the input [1,2,3] , the jq filter ‘.[]’ is not a valid jq filter as it results in multiple jq results. However, the jq filter ‘. | join(",")’ is valid as it results in one result: “1,2,3”. Refer to the jq manual for jq syntax and tips. |
json | (google.protobuf.Value )Static JSON value. For information about the value format, see the Google protocol buffer documentation. |