Home

Awesome

<br/> <h1 align='center'>Vite GraphQL Server</h1> <p align='center'>Bootstrap a local GraphQL server in your Vite project</p> <br/>

Introduction

This plugin helps you bootstrap a local GraphQL server in your Vite project with the minimum amount of setup and configuration. It is helpful for prototyping, local development, and debugging.

Getting Started

First, install the plugin:

npm install --save-dev vite-plugin-graphql-server

yarn add --dev vite-plugin-graphql-server

pnpm add --save-dev vite-plugin-graphql-server

Then, add the plugin to your vite.config.ts and pass in your GraphQL schema and resolvers:

import { defineConfig } from 'vite'
import GraphqlServer from 'vite-plugin-graphql-server'

export default defineConfig({
  plugins: [
    plugin({
      contextValue: {
        // Any context value that you want to be available in your resolvers
      },
      schema: {
        typeDefs: `
          type Query {
            hello: String!
          }
        `,
        resolvers: {
          Query: {
            hello: () => 'Hello World',
          },
        },
      },
    }),
  ],
})

Now, you can start your Vite server and your GraphQL server will be available at http://localhost:5173/__graphql.

Related Projects

License

Licensed under the MIT License.