javascript Usando tipos customizados没有graphql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Usando tipos customizados没有graphql相关的知识,希望对你有一定的参考价值。
import { GraphQLServer } from 'graphql-yoga'
// Scalar types - String, Boolean, Int, Float, ID
// Type definitions (schema)
const typeDefs = `
type Query {
me: User!
post: Post!
}
type User {
id: ID!
name: String!
email: String!
age: Int
}
type Post {
id: ID!
title: String!
body: String!
published: Boolean!
}
`
// Resolvers
const resolvers = {
Query: {
me() {
return {
id: '123098',
name: 'Mike',
email: 'mike@example.com'
}
},
post() {
return {
id: '092',
title: 'GraphQL 101',
body: '',
published: false
}
}
}
}
const server = new GraphQLServer({
typeDefs,
resolvers
})
server.start(() => {
console.log('The server is up!')
})
以上是关于javascript Usando tipos customizados没有graphql的主要内容,如果未能解决你的问题,请参考以下文章
javascript Usando导出没有javascript para organizar o codigo graphql
javascript Usando内存缓存com apolo客户端反应
javascript Os tipos升级没有graphql
csharp Enviar un fichero来自FTP usando C#para .NET
javascript Criaçãoderesolvers para os tipos querys
javascript Fazendoassociaçãentredois tipos no graphql e fazendo o resolver