Execute a GraphQL Query
To execute a GraphQL query, use thegraphql command followed by your query. The basic syntax is:
YOUR_QUERY_HERE with your actual GraphQL query.
Query Structure
Your GraphQL query should be a valid JSON string containing aquery key. For example:
Use Variables
You can include variables in your GraphQL query using the-v or --variables option. The variables should be provided as a JSON string. For example:
Raw Output
By default, the CLI formats the JSON response for readability. If you prefer the raw JSON output, use the--raw flag:
Example Queries
Here are some example GraphQL queries you can try with the Cobo WaaS 2 API:Fetch Wallet Information
Retrieve Transactions for a Wallet
Get MPC Vault Information with Variables
Error Handling
If there’s an error in your GraphQL query or during execution, the CLI will display the error message. Make sure to check the response for any error fields.Tips for Using GraphQL with Cobo CLI
-
Use the
--helpoption with thegraphqlcommand to see all available options: -
For complex queries, consider writing your query in a separate file and using command substitution to pass it to the CLI:
- Remember to escape special characters in your query string when using it directly in the command line.
- The GraphQL endpoint uses the same authentication method as other API commands. Ensure you’re properly authenticated before executing queries.
- Use the Cobo WaaS 2 API documentation to explore available GraphQL schemas and construct your queries accordingly.
By leveraging the power of GraphQL, you can efficiently retrieve exactly the data you need from the Cobo WaaS 2 API, reducing unnecessary data transfer and simplifying your API interactions.
Related Commands
cobo get: Execute GET requests to the Cobo APIcobo post: Execute POST requests to the Cobo APIcobo put: Execute PUT requests to the Cobo APIcobo delete: Execute DELETE requests to the Cobo API
