跳至正文
Wener Notes

graphql-yoga

约 1 分钟阅读
TypeScript
import { createSchema, createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';

const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        hello: String
      }
    `,
    resolvers: {
      Query: {
        hello: () => 'Hello from Yoga!',
      },
    },
  }),
});

const server = createServer(yoga);

server.listen(4000, () => {
  console.info('Server is running on http://localhost:4000/graphql');
});

upload

bash
curl localhost:4000/graphql \
  -F operations='{ "query": "mutation ($file: File!) { upload(file: $file){clientMutationId} }", "variables": { "file": null } }' \
  -F map='{ "0": ["variables.file"] }' \
  -F [email protected]

关联信息

反向链接、本文链接的其他页面和外部资料。

反向链接

  • GraphQL Awesome
    笔记 · graphql-yoga

    WebUI · graphql/graphiql · graphql/graphql-playground · https://www.graphqlbin.com/v2/new · graphql-kit/graphql-voyager · interactive graph

参考资料

GitHub2 条
最近更新commit 4d57414编辑