The documentation you are viewing is for Dapr v1.7 which is an older version of Dapr. For up-to-date documentation, see the latest version.
GraphQL binding spec
Component format
To setup GraphQL binding create a component of type bindings.graphql. See this guide on how to create and apply a binding configuration. To separate normal config settings (e.g. endpoint) from headers, “header:” is used a prefix on the header names.
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: example.bindings.graphql
spec:
  type: bindings.graphql
  version: v1
  metadata:
    - name: endpoint
      value:  http://localhost:8080/v1/graphql
    - name: header:x-hasura-access-key
      value: adminkey
    - name: header:Cache-Control
      value: no-cache
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.Spec metadata fields
| Field | Required | Binding support | Details | Example | 
|---|---|---|---|---|
| endpoint | Y | Output | GraphQL endpoint string See here for more details | "http://localhost:4000/graphql/graphql" | 
| header:[HEADERKEY] | N | Output | GraphQL header. Specify the header key in the name, and the header value in the value. | 
"no-cache" (see above) | 
Endpoint and Header format
The GraphQL binding uses GraphQL client internally.
Binding support
This component supports output binding with the following operations:
querymutation
query
The query operation is used for query statements, which returns the metadata along with data in a form of an array of row values.
Request
in := &dapr.InvokeBindingRequest{
Name:      "example.bindings.graphql",
Operation: "query",
Metadata: map[string]string{ "query": `query { users { name } }`},
}
Related links
- Basic schema for a Dapr component
 - Bindings building block
 - How-To: Trigger application with input binding
 - How-To: Use bindings to interface with external resources
 - Bindings API reference
 
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.