mirror of https://github.com/dapr/docs.git
graphql output binding variable support (#3286)
* Update graghql.md update the graphql doc corresponding to changes proposed by the contrib-packages pr #2517 wherein query variable support is added to the gql output binding Signed-off-by: chad <41795094+serpentfabric@users.noreply.github.com> * Update daprdocs/content/en/reference/components-reference/supported-bindings/graghql.md Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: chad <41795094+serpentfabric@users.noreply.github.com> --------- Signed-off-by: chad <41795094+serpentfabric@users.noreply.github.com> Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com>
This commit is contained in:
parent
c9fb86b6d8
commit
ab7a3b5b25
|
@ -39,6 +39,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr
|
|||
|--------------------|:--------:|------------|-----|---------|
|
||||
| endpoint | Y | Output | GraphQL endpoint string See [here](#url-format) 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) |
|
||||
| variable:[VARIABLEKEY] | N | Output | GraphQL query variable. Specify the variable name in the `name`, and the variable value in the `value`. | `"123"` (see below) |
|
||||
|
||||
### Endpoint and Header format
|
||||
|
||||
|
@ -65,6 +66,18 @@ Metadata: map[string]string{ "query": `query { users { name } }`},
|
|||
}
|
||||
```
|
||||
|
||||
To use a `query` that requires [query variables](https://graphql.org/learn/queries/#variables), add a key-value pair to the `metadata` map, wherein every key corresponding to a query variable is the variable name prefixed with `variable:`
|
||||
|
||||
```golang
|
||||
in := &dapr.InvokeBindingRequest{
|
||||
Name: "example.bindings.graphql",
|
||||
Operation: "query",
|
||||
Metadata: map[string]string{
|
||||
"query": `query HeroNameAndFriends($episode: string!) { hero(episode: $episode) { name } }`,
|
||||
"variable:episode": "JEDI",
|
||||
}
|
||||
```
|
||||
|
||||
## Related links
|
||||
|
||||
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
||||
|
|
Loading…
Reference in New Issue