Anchor to gateSubjectCreategate
gateSubjectCreate
mutationDeprecated
Requires access scope. Also: You must have write access to
gates
and write access to the subject type to create gate subjects.
For example, setting a gate on a requires the same access as mutating a
.
Creates a new Gate Subject. Gates API is being sunset and will be removed in a future version. Use metafields
instead for gate configuration.
Anchor to Arguments
Arguments
- Anchor to inputinput•Gate
Subject requiredCreate Input! Specifies the input fields for a gate configuation.
Was this section helpful?
Anchor to GateSubjectCreatePayload returnsGateSubjectCreatePayload returns
- Anchor to gateSubjectgate•
Subject The created gate subject.
- Anchor to userErrorsuser•
Errors [GateSubject non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a gate subject and return the gate subject ID
- gateSubjectCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
gateSubjectCreate(input: $input) {
userErrors {
field
message
}
gateSubject {
id
configuration {
id
}
active
createdAt
updatedAt
}
}
}`,
{
variables: {
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
gateSubjectCreate(input: $input) {
userErrors {
field
message
}
gateSubject {
id
configuration {
id
}
active
createdAt
updatedAt
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation gateSubjectCreate($input: GateSubjectCreateInput!) { gateSubjectCreate(input: $input) { userErrors { field message } gateSubject { id configuration { id } active createdAt updatedAt } } }",
"variables": {
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
gateSubjectCreate(input: $input) {
userErrors {
field
message
}
gateSubject {
id
configuration {
id
}
active
createdAt
updatedAt
}
}
}`,
{
variables: {
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
gateSubjectCreate(input: $input) {
userErrors {
field
message
}
gateSubject {
id
configuration {
id
}
active
createdAt
updatedAt
}
}
}`,
"variables": {
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
}
},
},
});
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
mutation gateSubjectCreate($input: GateSubjectCreateInput!) {
gateSubjectCreate(input: $input) {
userErrors {
field
message
}
gateSubject {
id
configuration {
id
}
active
createdAt
updatedAt
}
}
}
QUERY
variables = {
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"gateConfigurationId": "gid://shopify/GateConfiguration/589189056",
"subject": "gid://shopify/Product/840541035",
"active": false
}
}
Response
JSON{
"gateSubjectCreate": {
"userErrors": [],
"gateSubject": {
"id": "gid://shopify/GateSubject/974631523",
"configuration": {
"id": "gid://shopify/GateConfiguration/589189056"
},
"active": false,
"createdAt": "2024-09-12T01:10:00Z",
"updatedAt": "2024-09-12T01:10:00Z"
}
}
}