Wiki.js GraphQL:创建页面示例

问题描述

我是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"
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...