graphql

node v10.24.1
version: 1.0.2
endpointsharetweet
var express = require("@runkit/runkit/express-endpoint/1.0.0"); var graphqlHTTP = require("express-graphql"); var { buildSchema } = require("graphql"); //定义schema var schema = buildSchema(` type User { name: String sex: String intro: String } type Query { user:User } `); //定义服务端数据 var root = { user: { name: "UserName", sex: "Man", intro: "UserName is me." } }; var app = express(exports); app.use("/", graphqlHTTP({ schema: schema, rootValue: root, graphiql: true //启用GraphiQL }) ); app.listen(8080, () => console.log("localhost:8080/graphql"));
Loading…

no comments

    sign in to comment