Anchor to shop
shop
query
Returns the Shop resource corresponding to the access token used in the request. The Shop resource contains business and store management settings for the shop.
Anchor to Possible returnsPossible returns
- Anchor to ShopShop•
Represents a collection of general settings and information about the shop.
Was this section helpful?
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 query ShopMetafield($namespace: String!, $key: String!) {6 shop {7 copyrightYear: metafield(namespace: $namespace, key: $key) {8 value9 }10 }11 }`,12 {13 variables: {14 "namespace": "my_fields",15 "key": "copyright_year"16 },17 },18);1920const data = await response.json();21
query ShopMetafield($namespace: String!, $key: String!) {
shop {
copyrightYear: metafield(namespace: $namespace, key: $key) {
value
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ShopMetafield($namespace: String!, $key: String!) { shop { copyrightYear: metafield(namespace: $namespace, key: $key) { value } } }",
"variables": {
"namespace": "my_fields",
"key": "copyright_year"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ShopMetafield($namespace: String!, $key: String!) {
shop {
copyrightYear: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "copyright_year"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ShopMetafield($namespace: String!, $key: String!) {
shop {
copyrightYear: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
"variables": {
"namespace": "my_fields",
"key": "copyright_year"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ShopMetafield($namespace: String!, $key: String!) {
shop {
copyrightYear: metafield(namespace: $namespace, key: $key) {
value
}
}
}
QUERY
variables = {
"namespace": "my_fields",
"key": "copyright_year"
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "namespace": "my_fields",3 "key": "copyright_year"4}
Response
JSON1{2 "shop": {3 "copyrightYear": {4 "value": "2022"5 }6 }7}