Passing the Graphql schema as JSON request body in REST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2023 02:18 AM
Hi ,
I want to pass the Graphql schema as the JSON request body in REST Message.
This is my Grapql Query
- Labels:
-
graphql in rest
-
Graphql to json

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 07:49 AM - edited 06-09-2024 07:49 AM
You just need to wrap it:
like this:
{ "query": `{ places (orderBy: title_ASC,first: 100){ id title perex images { height src width } } }`, }
There a single property "query" that will contain your graphql query. You can do it as multiline string or I found this nice service: https://datafetcher.com/graphql-json-body-converter
{
"query": "query listComponents($input: ListComponentsInput) { services: listComponents(input: $input) { pageInfo { totalCount pageSize totalPages currentPage previousPage nextPage } items { service_long_id: componentId service_name: componentName service_id: componentCode service_desc: description division } }}Variables :{ \"input\": { \"filter\": { \"componentIds\": { \"in\": [] }, \"active\": { \"eq\": true }, \"lifeCycleStatus\": { \"ne\": \"Retired\" }, \"componentName\": { \"contains\": \"\" } }, \"pagination\": { \"size\": 3000, \"page\": 1 } }}"
}