javascript passagem de argumento para uma query graphql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript passagem de argumento para uma query graphql相关的知识,希望对你有一定的参考价值。

import { GraphQLServer } from 'graphql-yoga'

// Scalar types - String, Boolean, Int, Float, ID

// Type definitions (schema)
const typeDefs = `
    type Query {
        greeting(name: String, position: String): String!
        add(a: Float!, b: Float!): Float!
        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: {
        greeting(parent, args, ctx, info) {
            if (args.name && args.position) {
                return `Hello, ${args.name}! You are my favoriate ${args.position}.`
            } else {
                return 'Hello!'
            }
        },
        add(parent, args, ctx, info) {
            return args.a + args.b
        },
        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 passagem de argumento para uma query graphql的主要内容,如果未能解决你的问题,请参考以下文章

css 中心文本在veritcally。示例:滑块中的http://www.carrefour.com.ar/content/servicios/la-plaza-de-tu-mascota/文本。

JavaScript recogida de parametros de la url mediante javascript

javascript AR程序指导 - (行为)

javascript Ciclo de vida de los componentes

JavaScript Javascript - Listar propiedades de un objeto

JavaScript solo numeros en campo de texto javascript