Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVDOCS-5825: [new] Create store-metafields #480

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions docs/store-operations/catalog/graphql-admin/store-metafields
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Store metafields

Store metafields allow you to attach a metafield to the store itself. They are suitable for any global information against the store that is not channel specific. Channel metafields are appropriate for any storefront-specific data you need to store in metafields. There are two ways to create a store metafield in Admin GraphQL. You can remove the resource ID or use the store’s Global ID. Examples of each type are below:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zvuki do you think we should recommend one way of doing this over another?


## Remove resource ID

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example mutation: Create a store metafield" showLineNumbers copy
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json

mutation Metafield($input: CreateMetafieldInput!) {
metafield {
createMetafield(input: $input) {
metafield {
id
description
key
namespace
permissionSet
resourceId
value
ownerClientId
}
}
}
}
```
```json filename="GraphQL variables" showLineNumbers copy
{
"input":{
"namespace": "Warehouse Locations",
"key": "Location",
"value": "4HG",
"permissionSet": "APP_ONLY"
}
}
```
</Tab>
<Tab>

```json filename="Example mutation: Create a store metafield" showLineNumbers copy
{
"data": {
"metafield": {
"createMetafield": {
"metafield": {
"id": "bc/store/metafield/74",
"description": "",
"key": "'Location",
"namespace": Warehouse Locations",
"permissionSet": "APP_ONLY",
"resourceId": "bc/store/store/1001197568",
"value": "4HG",
"ownerClientId": "k8l7zz0ynkd1bfbxx02p2k7pnk3n8ov"
}
}
}
}
}
```
</Tab>
</Tabs>

## Use the Global ID

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example mutation: Create a store metafield" showLineNumbers copy
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json

mutation Metafield($input: CreateMetafieldInput!) {
metafield {
createMetafield(input: $input) {
metafield {
id
description
key
namespace
permissionSet
resourceId
value
ownerClientId
}
}
}
}
```
```json filename="GraphQL variables" showLineNumbers copy
{
"input":{
"namespace": "Warehouse Locations",
"key": "Location",
"value": "4HG",
"permissionSet": "APP_ONLY",
"resourceId": "bc/store/store/1001197568"
}
}
```
</Tab>
<Tab>

```json filename="Example mutation: Create a store metafield" showLineNumbers copy
{
"data": {
"metafield": {
"createMetafield": {
"metafield": {
"id": "bc/store/metafield/71",
"description": "",
"key": "'Location",
"namespace": Warehouse Locations",
"permissionSet": "APP_ONLY",
"resourceId": "bc/store/store/1001197568",
"value": "4HG",
"ownerClientId": "k8l7zz0ynkd1bfbxx02p2k7pnk3n8ov"
}
}
}
}
}
```
</Tab>
</Tabs>

<Callout typo="info">
You can create 10,000 metafields instead of the typical limit of 250 per entity-per-client-id.
</Callout>
Loading
Loading