javascript 查询e解析器简单com graphql-yoga

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 查询e解析器简单com graphql-yoga相关的知识,希望对你有一定的参考价值。

import { GraphQLServer } from 'graphql-yoga'

// Type definitions (schema)
const typeDefs = `
    type Query {
        hello: String!
        name: String!
        location: String!
        bio: String!
    }
`

// Resolvers
const resolvers = {
    Query: {
        hello() {
            return 'This is my first query!'
        },
        name() {
            return 'Andrew Mead'
        },
        location() {
            return 'Philadelphia'
        },
        bio() {
            return 'I live in Philly and teach on Udemy!'
        }
    }
}

const server = new GraphQLServer({
    typeDefs,
    resolvers
})

server.start(() => {
    console.log('The server is up!')
})

以上是关于javascript 查询e解析器简单com graphql-yoga的主要内容,如果未能解决你的问题,请参考以下文章