The documentation you are viewing is for Dapr v1.4 which is an older version of Dapr. For up-to-date documentation, see the latest version.

GraphQL binding spec

Detailed documentation on the GraphQL binding component

配置

To setup GraphQL binding create a component of type bindings.graphql. 请参阅本指南,了解如何创建和应用绑定配置。 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

元数据字段规范

字段 必填 绑定支持 详情 示例
终结点 Y 输出 GraphQL endpoint string See here for more details "http://localhost:4000/graphql/graphql"
header:[HEADERKEY] N 输出 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.

绑定支持

字段名为 ttlInSeconds

  • 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.

请求

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

相关链接