Graphql入门

Schema书写顺序

这里以github-schema.graphql为标准样本进行编写

  • interface
  • union
  • type
  • enum
  • input
  • scalar

学习入门网站

查找属性值顺序

schema

type PageTagRecordGroup {
    text: String!
}

type Query {
    pageTagRecordGroup(skip: Int): PageTagRecordGroup
}

resolvers

module.exports = {
    Query: {
        pageTagRecordGroup: async function () {
            return {
                text: 222
            }
        }
    },
    PageTagRecordGroup: {
        text: async function () {
            return 333
        }
    }
}

query

{
    pageTagRecordGroup(skip: 10) {
        text
    }
}

返回结果为

{
    "data": {
        "pageTagRecordGroup" {
            text: "333"
        }
    }
}
© 404mzk all right reserved,powered by Gitbookhttp://blog.404mzk.com 该文件修订时间: 2020-11-16 12:43:29

results matching ""

    No results matching ""