API-Verified Quest (GraphQL)
How to set up custom quest using GraphQL API.
Last updated
How to set up custom quest using GraphQL API.
Last updated
GraphQL verification takes a single wallet address or email as input and outputs 0(false)/1(true) to indicate whether the wallet address is eligible. It requires 3 fields to be filled in: GraphQL Endpoint (HTTPs), Query and Expression.
It's the HTTPs endpoint where Subgraph queries go to, see the example below.
NOTE: If you saw an error when testing the API, check if the endpoint is a valid GraphQL API endpoint. Common misconfigurations include:
Incorrectly used a GraphQL playground url, that usually ends with /graph
The GraphQL endpoint does now allow CORS from carv.io.
The GraphQL query requires a single wallet address as input. In the dashboard, once you finish your query, fill in a test address and click 'Run' button to check if the query's return is good.
A JavaScript (ES6) function with this type signature: (object) => int
. The function must be anonymous, which means that the first line of the expression should be like function(data) {
, instead of let expression = (data) => {
.
The function should return either number 1 or 0, representing if the address has completed the quest. Behind the scenes, first, we send the query with the user's address to the GraphQL endpoint, and then we will apply the function against the 'data' field of the response. If the returned value is 1, then user is considered to have completed this quest, otherwise not.
Once the query's output is good, click 'Run' button to check if expression processes the query's output correctly.
Endpoint
Query
Query Output
Expression
Expression Output