GraphQL
Pick GraphQL as a request's body type, then write the query and its variables (JSON). It's sent as a POST with query, variables and, when there's a choice, operationName.
- Schema: Fetch schema asks the endpoint for its schema (introspection), sent like the request itself: its auth, automatic login, pre-request scripts and certificates apply. The schema is kept per URL and environment, also after a restart; the refresh button asks again.
- With a schema:
- The query editor suggests fields, arguments, types and directives as you type (Ctrl+Space to ask), underlines what the schema doesn't have, and shows a field's type and description when you hover it.
- The variables editor suggests and checks each variable by its declared type.
- Operations: when the query holds several, pick the one to run; it's sent as
operationName. - Prettify formats the query. Comments aren't kept, and a
{{variable}}outside a string can't be formatted. - Schema explorer: Schema opens a pane with the root types. Follow a field's type to its fields, search every type and field by name, and click a field to insert it into the query.
{{variables}}work in the query and the variables. Outside a string they aren't GraphQL, so the checks leave them alone.
Subscriptions
A subscription runs over a WebSocket at the same URL (http becomes ws, https becomes wss), with the request's headers and auth in the handshake. Both the graphql-transport-ws protocol (the graphql-ws library) and the older subscriptions-transport-ws one are spoken; the server picks.
- Results appear in the response's Events view as they arrive, and Send becomes Stop.
- It ends when the server completes it, an error arrives, or you press Stop. The response body is the JSON array of every result, so a test can read it with
pm.response.json(). - In the Runner, Monitors and the CLI, a subscription ends after its first result, or at the request timeout.