问题描述
我是GraphQL的新手,我不知道如何为Wiki.js编写一个PageMutation
create
调用。他们的GraphQL游乐场位于public docs上。创建的模式为:
type PageMutation {
create(
content: String!
description: String!
editor: String!
isPublished: Boolean!
isPrivate: Boolean!
locale: String!
path: String!
publishEndDate: Date
publishStartDate: Date
scriptCss: String
scriptJs: String
tags: [String]!
title: String!
): PageResponse
在GraphQL docs页面上,他们说突变参数应声明为 input ,但不是。另外,我还没有看到关于这种结构(对象在对象中?)的描述,也看不到如何使用它。
欢迎您。 谢谢
解决方法
因此,这是一个页面创建的示例,该页面不包含变量,而仅包含变量本身:
mutation Page {
pages {
create (content:"contenuto",description:"descrizione",editor: "code",isPublished: true,isPrivate: false,locale: "it",path:"/",tags: ["tag1","tag2"],title:"titolo") {
responseResult {
succeeded,errorCode,slug,message
},page {
id,path,title
}
}
}
}
有关GraphQL docs的详细信息。
这是一个带有变量的示例:
mutation Page ($content: String!,$descrizione: String!,$editor:String!,$isPublished:Boolean!,$isPrivate:Boolean!,$locale:String!,$path:String!,$tags:[String]!,$title:String!) {
pages {
create (content:$content,description:$descrizione,editor: $editor,isPublished: $isPublished,isPrivate: $isPrivate,locale: $locale,path:$path,tags: $tags,title:$title) {
responseResult {
succeeded,title
}
}
}
}
查询变量:
{
"content": "contenuto","descrizione":"descrizione","editor": "code","isPublished": true,"isPrivate": false,"locale": "it","path":"/pagina01","tags": ["tag1","title":"titolo"
}