> Note: > The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the [GraphQL Admin API](/docs/api/admin-graphql). For details and migration steps, visit our [migration guide](/docs/apps/build/graphql/migrate). GraphQL queries retrieve data from a server, similar to a `GET` request for a REST API. However, unlike REST, GraphQL queries are sent to a single endpoint and use the `POST` HTTP method. A GraphQL API models data as nodes that are connected by edges. A node is an object that has a global ID, such as the [`Order`](/docs/api/admin-graphql/latest/objects/Order) or [`Product`](/docs/api/admin-graphql/latests/objects/Product) objects. You can fetch data about an individual node, or you can follow the edges to fetch data about a collection of related nodes. At each node, you specify the fields that you want to retrieve. ## QueryRoot The [`QueryRoot`](/docs/api/admin-graphql/latest/objects/queryroot) object is the initial entry point for all queries in the GraphQL API. Everything that can be queried is defined as a field or connection on the `QueryRoot` object. To learn about what data you can query, refer to the `QueryRoot` object in the relevant API's reference. > Note: > You don't need to reference the `QueryRoot` object in your query. ### Example The following diagram illustrates example relationships between objects that are retrieved in an query:
The relationships between the objects retrieved in the query.
The query requests the [`Shop`](/docs/api/admin-graphql/latest/objects/Shop) object, data from a few fields, the child [`ShopAddress`](/docs/api/admin-graphql/latest/objects/ShopAddress) object, and the `products` [connection](#connections). The following is the single request structure to retrieve this data. In the response, the structure of the `data` object mirrors the query's shape:

## Fields A field is unit of data associated with an object or type. For example, in the GraphQL Admin API's [`QueryRoot`](/docs/api/admin-graphql/latest/objects/queryroot) object, the [`customer`](/docs/api/admin-graphql/latest/objects/queryroot#field-queryroot-customer) field queries a single customer, and returns a [`Customer`](/docs/api/admin-graphql/latest/objects/Customer) object. An argument is a set of key-value pairs attached to a field, providing a parameterized input to the field that influences the returned data or an operation's behavior. For example, the `customer` field requires the `id` argument, which specifies the customer to query. After selecting the `customer` field and providing an ID, you list the fields on the `Customer` object that you want to return. To learn about what data you can query, refer the object's fields in the relevant API's reference. ### Example The following query retrieves a specific customer, and selects a few fields from the [`Customer`](/docs/api/admin-graphql/latest/objects/Customer) object:

%

> Tip: > On many endpoints, the REST Admin API returns the `admin_graphql_api_id` property, which you can use to query that specific object in the GraphQL Admin API. [Learn more](/docs/apps/build/graphql/migrate/learn-how#translating-ids-from-rest-to-graphql). ## Connections Connections in GraphQL represent relationships between associated types. Nodes are elements within connections. You can traverse connections to perform nested queries, retrieving data from multiple nodes in a single GraphQL query. If you're selecting something with a pluralized name, then you're likely using a connection. When you select a connection, you must pass a `first` or `last` argument to limit the number of nodes that are returned. This is a key component to manage [rate-limiting](/docs/api/usage/rate-limits) and [pagination](/docs/api/usage/pagination-graphql). You can access the nodes in a connection in the following ways: - **`edges`**: `customers { edges { node { ... } } }` - **`nodes`**: `customers { nodes { ... } }` > Tip: > `nodes` is shorthand for `edges { node ...` and is appropriate for most queries. To retrieve information that's specific to the connection between a node and its parent, you might want to use `edges`. [Learn more](/docs/api/usage/pagination-graphql#connection-edges). Regardless of the syntax that you use, the return is an array of objects of the same type. For example, when you query a product's variants, an array of `Variant` objects is returned. Similar to when you query an individual node, list the fields to return. The response returns that data for those fields for each node in the connection. If a connection contains fewer objects than requested, then the response contains all the data that's available. If you want to retrieve the next batch of objects, or you need to retrieve more than the maximum number of objects, then you can paginate the objects using [cursor-based pagination](/docs/api/usage/pagination-graphql). ### Example The following diagram illustrates example relationships between GraphQL types in a connection, including the connection, its constituent edges and nodes, and the associated objects and fields:
You can query the edges of the product connection to access product objects.
The example requests the `products` connection, and asks for the first three products. Because the [`Product`](/docs/api/admin-graphql/latest/objects/Product) object has a [`variants`](/docs/api/admin-graphql/latest/objects/Product#connection-product-variants) connection, the same pattern is used to get information on the first three variants for the original products:

In the response, only one set of data is returned because the store only has a single product and variant. ## Filtering connections using a search query You can filter connections with `query` argument, to return only the nodes that match a search query. To learn which fields you can filter a connection by, refer to the API documentation for the connection's `query` argument. To learn how to format a search query, refer to [Search syntax](/docs/api/usage/search-syntax). The following query retrieves the first two orders that are fulfilled:

## Next steps Learn how to create and modify data with [mutations](/docs/apps/build/graphql/basics/mutations).