Requesting data from a GraphQL server
In addition to requesting data from a REST API, you can also request data from a GraphQL server. Let's use the following example from Github's API docs:
js
query {
repository(owner: "octocat", name: "Hello-World") {
issues(last: 20, states: CLOSED) {
edges {
node {
title
url
labels(first: 5) {
edges {
node {
name
}
}
}
}
}
}
}
}
To perform this request in Wized, first create a Body field called query
, and then include the query as a string value using template literals:
When you're using template literals you can inject values into your string, including data from your Wized data store with ${}
.
In the example above, some request data is injected like this:
js
`owner: ${r.get_user.data.name}`;