Queries
This part of the GraphQL API is currently in Early Availability status. For more information, see GraphQL API policy.
Queries return information in JSON objects. To build a GraphQL query, you identify the data that you want to retrieve. When you build a query, you must identify specific fields at the scalar level, which might be nested within other fields.
Queries are requests to read data, similar to GET
requests in a REST
API.
Queries follow this pattern:
query {
object1
object2 {
sub-field1
sub-field2
}
...
objectN
}
Example
A query to list all marketplace products might look like this:
query{
products{
nodes{
name
id
vendorId
type
}
}
}
In this example, the name
, id
, vendorId
, and type
fields are all
scalars. It would not be possible to only request the products
object.
The response to the query above looks like this:
{
"data": {
"products": {
"nodes": [
{
"name": "MySampleProduct",
"id": "8a61cf55-1f2f-489c-8afb-052a5e2f9f91",
"vendorId": "ce0a5582-2601-4080-b969-99f949492982",
"type": "WEB_APP"
},
{
"name": "MyOtherProduct",
"id": "8d7200d3-975d-4cc4-9c09-1e8d8a16f066",
"vendorId": "ce0a5582-2601-4080-b969-99f949492982",
"type": "WEB_APP"
},
...
]
}
}
}
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!