๐ ์ด์ Gato GraphQL์์ ๋ฉํ ๊ฐ์ ๋ฎคํ ์ด์ ํ ์ ์์ต๋๋ค
์ค๋ Gato GraphQL v11.3์ด ์ถ์๋์์ต๋๋ค. ์ค์ํ ๊ธฐ๋ฅ์ด ์ถ๊ฐ๋์์ต๋๋ค: ๋ฉํ ๋ฎคํ
์ด์
!
์ปค์คํ ๊ฒ์๋ฌผ, ํ๊ทธ, ์นดํ ๊ณ ๋ฆฌ, ๋๊ธ, ์ฌ์ฉ์์ ๋ํด ๋ฉํ ๊ฐ์ ์ถ๊ฐ, ์ ๋ฐ์ดํธ, ์ญ์ ํ ์ ์๊ฒ ๋์์ต๋๋ค.
์๋์ ๋ฉํ๋ฅผ ๋ฎคํ ์ด์ ํ๋ ์ฟผ๋ฆฌ ์์๋ฅผ ์๊ฐํฉ๋๋ค.
๋ฉํ ์ถ๊ฐ
์ปค์คํ ๊ฒ์๋ฌผ, ํ๊ทธ, ์นดํ ๊ณ ๋ฆฌ, ๋๊ธ, ์ฌ์ฉ์์ ๋ฉํ ํญ๋ชฉ์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
์ด ์ฟผ๋ฆฌ๋ ID 4์ธ ๊ฒ์๋ฌผ์ ๋ฉํ ํญ๋ชฉ์ ์ถ๊ฐํฉ๋๋ค:
mutation {
addCustomPostMeta(input: {
id: 4
key: "some_key"
value: "Some value"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
id
metaValue(key: "some_key")
}
}
}์ด ์ฟผ๋ฆฌ๋ ๋์ผํ ๋ฉํ ํค์ ์๋ก ๋ค๋ฅธ ๊ฐ์ ์ฌ๋ฌ ๊ฒ์๋ฌผ์ ์ผ๊ด์ ์ผ๋ก ์ถ๊ฐํฉ๋๋ค:
mutation {
addCustomPostMetas(inputs: [
{
id: 4
key: "some_key"
value: "Some value"
},
{
id: 5
key: "some_key"
value: "Some other value"
},
{
id: 6
key: "some_key"
value: "Yet another value"
}
]) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
id
metaValue(key: "some_key")
}
}
}๋ฉํ ์ ๋ฐ์ดํธ
์นดํ ๊ณ ๋ฆฌ ๋ฉํ ํญ๋ชฉ์ ์ ๋ฐ์ดํธํฉ๋๋ค:
mutation {
updateCategoryMeta(input: {
id: 20
key: "_source"
value: "Updated source value"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
category {
__typename
id
metaValue(key: "_source")
}
}
}์ด ์ฟผ๋ฆฌ๋ ์ค์ฒฉ ๋ฎคํ ์ด์ ์ ์ฌ์ฉํ์ฌ ๊ฒ์๋ฌผ์ ๋ฉํ ๊ฐ์ ์ ๋ฐ์ดํธํฉ๋๋ค:
mutation {
post(by: {id: 1}) {
updateMeta(input: {
key: "some_key"
value: "Updated description"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
metaValue(key: "single_meta_key")
}
}
}
}๋ฉํ ์ญ์
๊ฒ์๋ฌผ์์ ๋ฉํ ํญ๋ชฉ์ ์ญ์ ํฉ๋๋ค:
mutation {
deletePostMeta(input: {
id: 5
key: "some_key"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
metaValue(key: "some_key")
}
}
}์ฌ๋ฌ ๊ฒ์๋ฌผ์์ ๋์ผํ ๋ฉํ ํญ๋ชฉ์ ์ผ๊ด์ ์ผ๋ก ์ญ์ ํฉ๋๋ค:
mutation {
deletePostMetas(inputs: [
{
id: 5
key: "some_key"
},
{
id: 6
key: "some_key"
}
]) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
metaValue(key: "some_key")
}
}
}์ฌ๋ฌ ๋ฉํ ํญ๋ชฉ์ ํ ๋ฒ์ ์ค์ ํ๊ธฐ
๋ค์ํ set{Entity}Meta ๋ฎคํ
์ด์
์ JSON์ ์ ๋ฌํ์ฌ ์ฌ๋ฌ ๋ฉํ ํญ๋ชฉ์ ํ ๋ฒ์ ์ค์ ํ ์ ์์ต๋๋ค:
mutation {
setCustomPostMeta(input: {
id: 4
entries: {
single_meta_key: [
"This is a single entry",
],
object_meta_key: [
{
key: "This is a key",
value: "This is a value",
},
],
array_meta_key: [
"This is a string",
"This is another string",
],
object_array_meta_key: [
[
{
key: "This is a key 1",
value: "This is a value 1",
},
{
key: "This is a key 2",
value: "This is a value 2",
},
]
],
}
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
id
meta(keys: ["single_meta_key", "object_meta_key", "array_meta_key", "object_array_meta_key"])
}
}
}์ํฐํฐ ์์ฑ/์ ๋ฐ์ดํธ ์ ๋ฉํ ํญ๋ชฉ ์ค์ ํ๊ธฐ
์ปค์คํ
๊ฒ์๋ฌผ, ํ๊ทธ, ์นดํ
๊ณ ๋ฆฌ, ๋๋ ๋๊ธ์ ์์ฑํ๊ฑฐ๋ ์
๋ฐ์ดํธํ ๋ meta ํ๋ผ๋ฏธํฐ๋ฅผ ํตํด ์ง์ ๋ฉํ ํญ๋ชฉ์ ์ ์ํ ์ ์์ต๋๋ค.
์ด ์ฟผ๋ฆฌ๋ ๋๊ธ์ ์ถ๊ฐํ ๋ ๋ฉํ๋ฅผ ์ค์ ํฉ๋๋ค:
mutation {
addCommentToCustomPost(input: {
customPostID: 1130
commentAs: { html: "New comment" }
meta: {
some_meta_key: [
"This is a single entry",
],
another_meta_key: [
"This is an array entry 1",
"This is an array entry 2",
],
}
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
comment {
id
meta(keys: ["some_meta_key", "another_meta_key"])
}
}
}์ด ์ฟผ๋ฆฌ๋ ์ค์ฒฉ ๋ฎคํ
์ด์
Post.update์ ๋ฉํ๋ฅผ ์ฃผ์
ํฉ๋๋ค:
mutation {
post(by: {id: 1}) {
update(input: {
meta: {
single_meta_key: [
"This is an updated value",
]
}
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
metaValue(key: "single_meta_key")
}
}
}
}