You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bootstrap a local GraphQL server in your Vite project
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.
Then, add the plugin to your vite.config.ts and pass in your GraphQL schema
and resolvers:
import{defineConfig}from'vite'importGraphqlServerfrom'vite-plugin-graphql-server'exportdefaultdefineConfig({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
https://localhost:5173/__graphql.
Related Projects
vite-plugin-graphiql:
Integrate GraphiQL IDE in your Vite projects. It is a great companion to this
plugin. You can use it to explore your GraphQL schema and execute queries
against your local GraphQL server.
@graphql-utils/store: In-memory data
store for writing stateful GraphQL mocks. You can use it to store data in your
GraphQL server and use it in your resolvers without having to set up a
database.