GraphQL binding spec

Detailed documentation on the GraphQL binding component

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.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: example.bindings.graphql
  5. spec:
  6. type: bindings.graphql
  7. version: v1
  8. metadata:
  9. - name: endpoint
  10. value: http://localhost:8080/v1/graphql
  11. - name: header:x-hasura-access-key
  12. value: adminkey
  13. - name: header:Cache-Control
  14. 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

FieldRequiredBinding supportDetailsExample
endpointYOutputGraphQL endpoint string See here for more detailshttp://localhost:4000/graphql/graphql
header:[HEADERKEY]NOutputGraphQL 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:

  • query
  • mutation

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

  1. in := &dapr.InvokeBindingRequest{
  2. Name: "example.bindings.graphql",
  3. Operation: "query",
  4. Metadata: map[string]string{ "query": `query { users { name } }`},
  5. }

Last modified February 18, 2022: Update setup-jetstream.md (#2200) (428d8c2)