<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          GraphQL ServerGraphQL 服務(wù)器

          聯(lián)合創(chuàng)作 · 2023-09-19 18:58

          這是一個(gè) GraphQL 服務(wù)器,支持 Express, Connect, Hapi 和 Koa

          示例代碼:

          Express:

          import express from 'express';
          import bodyParser from 'body-parser';
          import { graphqlExpress } from 'graphql-server-express';
          
          const myGraphQLSchema = // ... define or import your schema here!
          const PORT = 3000;
          
          var app = express();
          
          // bodyParser is needed just for POST.
          app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: myGraphQLSchema }));
          
          app.listen(PORT);

          Connect:

          import connect from 'connect';
          import bodyParser from 'body-parser';
          import { graphqlConnect } from 'graphql-server-express';
          import http from 'http';
          
          const PORT = 3000;
          
          var app = connect();
          
          // bodyParser is needed just for POST.
          app.use('/graphql', bodyParser.json());
          app.use('/graphql', graphqlConnect({ schema: myGraphQLSchema }));
          
          http.createServer(app).listen(PORT);

          Hapi:

          import hapi from 'hapi';
          import { graphqlHapi } from 'graphql-server-hapi';
          
          const server = new hapi.Server();
          
          const HOST = 'localhost';
          const PORT = 3000;
          
          server.connection({
              host: HOST,
              port: PORT,
          });
          
          server.register({
              register: graphqlHapi,
              options: {
                path: '/graphql',
                graphqlOptions: {
                  schema: myGraphQLSchema,
                },
                route: {
                  cors: true
                }
              },
          });
          
          server.start((err) => {
              if (err) {
                  throw err;
              }
              console.log(`Server running at: ${server.info.uri}`);
          });
          瀏覽 14
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日韩性爱AV | 搞搞香蕉影 | 日韩国产精品一级毛片在线 | 天天操屄 | sese av |