fengyun2 / graphql-tutorial

graphql-tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

graphql-tutorial

##express-graphql:

  • graphql-lesson01
  • graphql-lesson02(graphql-curd)

##koa-graphql:

  • graphql-lesson03

总结

graphql 中也存在增删改查

查: query

// 查询
query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
        count: {
            type: GraphQLInt,
            // add the description
            description: 'The count!',
            resolve () {
                return count
            }
        }
    }
}),

增删改: mutation

// 增删改
mutation: new GraphQLObjectType({
    name: 'RootMutationType',
    fields: {
        updateCount: {
            type: GraphQLInt,
            description: 'Update the count',
            resolve (parentValue, args, request) {
                count += 1
                return count
            }
        }
    }
})

About

graphql-tutorial


Languages

Language:JavaScript 100.0%