How do I query batch this:…
- User
How do I query batch this:
{"operationName":"Login","variables":{"loginToken":"eyJxxxxxxxxxxxxxxxxxxxxxxxx","tfaCode":"111111"},"query":"mutation Login(tfaCode: String!) {\n login(loginToken: tfaCode) {\n accessToken\n refreshToken\n __typename\n }\n}"}
- Assistant
To send a batch query with the given JSON, you can modify it as follows:
code[ { "id": "1", "operationName": "Login", "variables": { "loginToken": "eyJxxxxxxxxxxxxxxxxxxxxxxxx", "tfaCode": "111111" }, "query": "mutation Login($loginToken: String!, $tfaCode: String!) {\n login(loginToken: $loginToken, tfaCode: $tfaCode) {\n accessToken\n refreshToken\n __typename\n }\n}" } ]The changes made are:
- Wrapping the existing JSON object in an array
[ ] - Adding an
idfield to identify the individual query within the batch (e.g., "1")
Now, you can make a POST request to the relevant GraphQL endpoint with this JSON payload to execute the batch query.
- Wrapping the existing JSON object in an array
- User
How do I send 2 at a time?
- Assistant
To send multiple queries in a batch, you can include multiple objects within the JSON array. Here's an example of sending two queries at a time:
json[ { "id": "1", "operationName": "Login", "variables": { "loginToken": "eyJxxxxxxxxxxxxxxxxxxxxxxxx", "tfaCode": "111111" }, "query": "mutation Login($loginToken: String!, $tfaCode: String!) {\n login(loginToken: $loginToken, tfaCode: $tfaCode) {\n accessToken\n refreshToken\n __typename\n }\n}" }, { "id": "2", "operationName": "GetUser", "variables": {}, "query": "query GetUser {\n user {\n id\n name\n email\n __typename\n }\n}" } ]In this example, there are two objects within the array: one for the "Login" mutation and another for the "GetUser" query. Each object includes an
idfield to identify the individual queries. You can add as many objects as needed within the array.