manufacturers
Fetches a paginated list of manufacturers.
Query Structure
query {
manufacturers(
first: Int,
after: String,
last: Int,
before: String
) {
edges {
node {
id
name
description
}
cursor
}
nodes {
id
name
description
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
totalCount
}
}
Arguments
Argument | Type | Description | Required | Default Value |
---|---|---|---|---|
first | Int | Returns the first n elements. | No | None |
after | String | Returns elements after this cursor. | No | None |
last | Int | Returns the last n elements. | No | None |
before | String | Returns elements before this cursor. | No | None |
Return Type
ManufacturerConnection
A connection to a list of Manufacturer items.
Field | Type | Description |
---|---|---|
edges | [ManufacturerEdge] | A list of edges, each containing a node and cursor. Optional. |
nodes | [Manufacturer] | A list of Manufacturer nodes. Optional. |
pageInfo | PageInfo! | Pagination information. Required. |
totalCount | Int | The total number of Manufacturer items. Optional. |
ManufacturerEdge
Field | Type | Description |
---|---|---|
node | Manufacturer | The Manufacturer item. |
cursor | String | Cursor for pagination. |
Manufacturer
Field | Type | Description |
---|---|---|
id | Int | Unique identifier of the manufacturer. |
name | String | Name of the manufacturer. |
description | String | Description of the manufacturer. |
PageInfo
Field | Type | Description |
---|---|---|
hasNextPage | Boolean | Indicates if there is a next page. |
hasPreviousPage | Boolean | Indicates if there is a previous page. |
startCursor | String | Cursor to the first item in the page. |
endCursor | String | Cursor to the last item in the page. |
Examples
Basic Query
query {
manufacturers(first: 5) {
nodes {
id
name
}
totalCount
}
}
Advanced Query
query {
manufacturers(first: 3, after: "YXJyYXljb25uZWN0aW9uOjI=") {
edges {
node {
id
name
description
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
totalCount
}
}
Field Selection
query {
manufacturers(last: 4) {
nodes {
id
name
description
}
pageInfo {
hasPreviousPage
startCursor
}
}
}
cURL Example
curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \
-H "Content-Type: application/json" \
-d '{"query":"query { manufacturers(first: 3) { nodes { id name description } totalCount } }"}'
JavaScript Example
async function fetchManufacturers() {
const query = `
query {
manufacturers(first: 3) {
nodes {
id
name
description
}
totalCount
}
}
`;
try {
const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ query })
});
const result = await response.json();
if (result.errors) {
console.error('GraphQL errors:', result.errors);
return;
}
console.log('Manufacturers:', result.data.manufacturers.nodes);
console.log('Total count:', result.data.manufacturers.totalCount);
} catch (error) {
console.error('Network error:', error);
}
}
fetchManufacturers();
Response Format
{
"data": {
"manufacturers": {
"edges": [
{
"node": {
"id": 123,
"name": "Acme Corp",
"description": "Leading manufacturer of widgets."
},
"cursor": "cursorString"
}
],
"nodes": [
{
"id": 123,
"name": "Acme Corp",
"description": "Leading manufacturer of widgets."
}
],
"pageInfo": {
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": "cursorString",
"endCursor": "cursorString"
},
"totalCount": 50
}
}
}
Error Handling
Error Code | Description | Resolution |
---|---|---|
BAD_USER_INPUT | Invalid argument values (e.g., negative first ) | Check and correct argument values. |
INTERNAL_SERVER_ERROR | Server encountered an unexpected condition | Retry the request after some time. |
GRAPHQL_PARSE_FAILED | Malformed GraphQL query | Verify query syntax and structure. |
In case of errors, the response will include an errors
array with detailed messages:
{
"errors": [
{
"message": "Argument 'first' must be a positive integer.",
"locations": [{ "line": 2, "column": 18 }],
"extensions": { "code": "BAD_USER_INPUT" }
}
]
}
Performance Considerations
- Use pagination arguments (
first
,after
,last
,before
) to limit the amount of data returned and improve response times. - Avoid requesting large numbers of items in a single query to reduce server load and latency.
- Cache responses where possible, especially for queries that do not change frequently.
- Monitor rate limits to avoid throttling (see API rate limiting policies).
- Use cursor-based pagination (
after
/before
) for efficient navigation through large datasets.
Authentication
This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.
Related Types
- ManufacturerConnection: The connection type for paginated manufacturer data.
- ManufacturerEdge: Edge type containing a manufacturer node and cursor.
- Manufacturer: Represents a manufacturer entity.
- PageInfo: Contains pagination metadata.
Notes
- Pagination cursors (
after
andbefore
) are opaque strings returned in thecursor
field of edges. - Use
totalCount
to understand the full size of the dataset. - The query supports both forward (
first
andafter
) and backward (last
andbefore
) pagination. - The
edges
field provides both the node and cursor, useful for implementing cursor-based pagination UI. - The
nodes
field provides a simplified list of manufacturer objects without cursors.
Last updated on