GraphQL
Send GraphQL queries and mutations with variables and headers, and read the schema of a server. Typical uses: read data from a GraphQL API.
graphql query <url> <query>
Description
Run a query or a mutation. JSON {ok, status, data, errors, error_count, extensions}. ok is true only when the status is 2xx and there is no error: a server that answers 200 with errors gives ok false, with the partial data and the errors side by side. A response that is not JSON gives ok false too. A network failure is an error.
Run a query or a mutation. JSON {ok, status, data, errors, error_count, extensions}. ok is true only when the status is 2xx and there is no error: a server that answers 200 with errors gives ok false, with the partial data and the errors side by side. A response that is not JSON gives ok false too. A network failure is an error.
Parameters
url: The URL - String - required
query: The GraphQL document - String - required
url: The URL - String - required
query: The GraphQL document - String - required
admin
graphql query "http://127.0.0.1:22004/graphql" "{ hello }"
mentdb
{"ok": true, "status": 200, "data": {"hello": "Hello world"}, "errors": null, "error_count": 0, "extensions": null}
Fixed result from a real call to a local test server (127.0.0.1): status 200 with errors and partial data: ok is false (ariadne server)
admin
graphql query "http://127.0.0.1:22004/graphql" "{ hello boom }"
mentdb
{"ok": false, "status": 200, "data": {"boom": null, "hello": "Hello world"}, "errors": [{"locations": [{"column": 9, "line": 1}], "message": "boom happened", "path": ["boom"]}], "error_count": 1, "extensions": null}
graphql query <url> <query> <json_variables>
Description
Run a query with variables
Run a query with variables
Parameters
url: The URL - String - required
query: The GraphQL document - String - required
json_variables: The variables as a JSON object, empty for none - String - required
url: The URL - String - required
query: The GraphQL document - String - required
json_variables: The variables as a JSON object, empty for none - String - required
admin
graphql query "http://127.0.0.1:22004/graphql" "query H($n: String) { hello(name: $n) }" "{\"n\": \"Ana\"}"
mentdb
{"ok": true, "status": 200, "data": {"hello": "Hello Ana"}, "errors": null, "error_count": 0, "extensions": null}
graphql query <url> <query> <json_variables> <json_params>
Description
Run a query with parameters: bearer (the token), headers (object), operation_name, fail_on_errors (true: an error instead of ok false), timeout_ms (the whole call), max_bytes (of the response), ca_file (PEM file of private certification authorities), insecure (true: no check of the certificate, the result then has tls_verified false), allow_http (true: allow plain http outside the local machine)
Run a query with parameters: bearer (the token), headers (object), operation_name, fail_on_errors (true: an error instead of ok false), timeout_ms (the whole call), max_bytes (of the response), ca_file (PEM file of private certification authorities), insecure (true: no check of the certificate, the result then has tls_verified false), allow_http (true: allow plain http outside the local machine)
Parameters
url: The URL - String - required
query: The GraphQL document - String - required
json_variables: The variables, empty for none - String - required
json_params: The parameters - String - required
url: The URL - String - required
query: The GraphQL document - String - required
json_variables: The variables, empty for none - String - required
json_params: The parameters - String - required
admin
graphql query "http://127.0.0.1:22004/auth" "{ hello }" "" "{\"bearer\": \"tok-abc123\", \"timeout_ms\": 5000}"
mentdb
{"ok": true, "status": 200, "data": {"hello": "Hello world"}, "errors": null, "error_count": 0, "extensions": null}
Fixed result from a real call to a local test server (127.0.0.1): fail_on_errors (ariadne server)
admin
graphql query "http://127.0.0.1:22004/graphql" "{ nofield }" "" "{\"fail_on_errors\": true}"
mentdb
Sorry, an error appears (the GraphQL server answered with errors (HTTP status 400): Cannot query field 'nofield' on type 'Query'.).
graphql introspect <url>
Description
Read the schema of a server: JSON {ok, status, query_type, mutation_type, subscription_type, types, errors}, each type with name, kind, fields (name, type written as [String!]!, args), input_fields, enum_values. Many production servers disable introspection: ok is then false and errors says so
Read the schema of a server: JSON {ok, status, query_type, mutation_type, subscription_type, types, errors}, each type with name, kind, fields (name, type written as [String!]!, args), input_fields, enum_values. Many production servers disable introspection: ok is then false and errors says so
Parameters
url: The URL - String - required
url: The URL - String - required
admin
graphql introspect "http://127.0.0.1:22004/graphql"
mentdb
{"ok": true, "status": 200, "query_type": "Query", "mutation_type": "Mutation", "subscription_type": null, "types": [{"name": "Query", "kind": "OBJECT", "fields": [{"name": "hello", "type": "String!", "args": [{"name": "name", "type": "String"}]}, {"name": "books", "type": "[Book!]!", "args": [{"name": "first", "type": "Int"}]}, {"name": "boom", "type": "String"}, {"name": "nb", "type": "Float"}, {"name": "big", "type": "String"}, {"name": "me", "type": "String"}], "input_fields": [], "enum_values": []}, {"name": "String", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Int", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Float", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Mutation", "kind": "OBJECT", "fields": [{"name": "add", "type": "Book!", "args": [{"name": "title", "type": "String!"}]}], "input_fields": [], "enum_values": []}, {"name": "Book", "kind": "OBJECT", "fields": [{"name": "id", "type": "ID!"}, {"name": "title", "type": "String!"}, {"name": "status", "type": "Status"}, {"name": "tags", "type": "[String!]"}], "input_fields": [], "enum_values": []}, {"name": "ID", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Status", "kind": "ENUM", "fields": [], "input_fields": [], "enum_values": ["DRAFT", "PUBLISHED"]}, {"name": "Filter", "kind": "INPUT_OBJECT", "fields": [], "input_fields": [{"name": "q", "type": "String"}, {"name": "limit", "type": "Int"}], "enum_values": []}, {"name": "Boolean", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}], "errors": null}
graphql introspect <url> <json_params>
Description
The same with parameters: bearer, headers, include_internal (true: also the __ types), timeout_ms (the whole call), max_bytes (of the response), ca_file (PEM file of private certification authorities), insecure (true: no check of the certificate, the result then has tls_verified false), allow_http (true: allow plain http outside the local machine)
The same with parameters: bearer, headers, include_internal (true: also the __ types), timeout_ms (the whole call), max_bytes (of the response), ca_file (PEM file of private certification authorities), insecure (true: no check of the certificate, the result then has tls_verified false), allow_http (true: allow plain http outside the local machine)
Parameters
url: The URL - String - required
json_params: The parameters - String - required
url: The URL - String - required
json_params: The parameters - String - required
admin
graphql introspect "http://127.0.0.1:22004/graphql" "{\"timeout_ms\": 5000, \"headers\": {\"X-Tenant\": \"demo\"}}"
mentdb
{"ok": true, "status": 200, "query_type": "Query", "mutation_type": "Mutation", "subscription_type": null, "types": [{"name": "Query", "kind": "OBJECT", "fields": [{"name": "hello", "type": "String!", "args": [{"name": "name", "type": "String"}]}, {"name": "books", "type": "[Book!]!", "args": [{"name": "first", "type": "Int"}]}, {"name": "boom", "type": "String"}, {"name": "nb", "type": "Float"}, {"name": "big", "type": "String"}, {"name": "me", "type": "String"}], "input_fields": [], "enum_values": []}, {"name": "String", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Int", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Float", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Mutation", "kind": "OBJECT", "fields": [{"name": "add", "type": "Book!", "args": [{"name": "title", "type": "String!"}]}], "input_fields": [], "enum_values": []}, {"name": "Book", "kind": "OBJECT", "fields": [{"name": "id", "type": "ID!"}, {"name": "title", "type": "String!"}, {"name": "status", "type": "Status"}, {"name": "tags", "type": "[String!]"}], "input_fields": [], "enum_values": []}, {"name": "ID", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}, {"name": "Status", "kind": "ENUM", "fields": [], "input_fields": [], "enum_values": ["DRAFT", "PUBLISHED"]}, {"name": "Filter", "kind": "INPUT_OBJECT", "fields": [], "input_fields": [{"name": "q", "type": "String"}, {"name": "limit", "type": "Int"}], "enum_values": []}, {"name": "Boolean", "kind": "SCALAR", "fields": [], "input_fields": [], "enum_values": []}], "errors": null}
