graphiql
GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
Top Related Projects
🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
A reference implementation of GraphQL for JavaScript
:rocket: A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Code-First, Type-Safe, GraphQL Schema Construction
Awesome list of GraphQL
Quick Overview
GraphiQL is an interactive in-browser GraphQL IDE. It provides a user-friendly interface for writing, validating, and testing GraphQL queries, making it an essential tool for developers working with GraphQL APIs.
Pros
- Easy-to-use interface for exploring and testing GraphQL APIs
- Built-in documentation explorer for schema introspection
- Supports query history and variables
- Customizable and embeddable in other applications
Cons
- Limited advanced features compared to some other GraphQL tools
- May require additional setup for certain authentication methods
- Performance can be slow with very large schemas
- Not suitable for production use (intended for development and testing)
Code Examples
- Basic usage of GraphiQL React component:
import { GraphiQL } from 'graphiql';
import 'graphiql/graphiql.min.css';
function App() {
return (
<GraphiQL
fetcher={async (graphQLParams) => {
const data = await fetch(
'https://api.example.com/graphql',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(graphQLParams),
credentials: 'same-origin',
},
);
return data.json();
}}
/>
);
}
- Customizing GraphiQL with a default query:
import { GraphiQL } from 'graphiql';
const defaultQuery = `
query {
user(id: "1") {
name
email
}
}
`;
function App() {
return (
<GraphiQL
fetcher={/* ... */}
defaultQuery={defaultQuery}
/>
);
}
- Adding custom headers to GraphiQL:
import { GraphiQL } from 'graphiql';
function App() {
const fetcher = async (graphQLParams) => {
const response = await fetch('https://api.example.com/graphql', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN_HERE',
},
body: JSON.stringify(graphQLParams),
});
return response.json();
};
return <GraphiQL fetcher={fetcher} />;
}
Getting Started
To use GraphiQL in your project:
-
Install the package:
npm install graphiql
-
Import and use the GraphiQL component in your React application:
import { GraphiQL } from 'graphiql'; import 'graphiql/graphiql.min.css'; function App() { return ( <GraphiQL fetcher={async (graphQLParams) => { const response = await fetch('YOUR_GRAPHQL_ENDPOINT', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(graphQLParams), }); return response.json(); }} /> ); }
-
Customize the component as needed with additional props and styling.
Competitor Comparisons
🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
Pros of GraphQL Playground
- More feature-rich interface with tabs, schema explorer, and settings
- Better support for GraphQL subscriptions
- Enhanced query history and sharing capabilities
Cons of GraphQL Playground
- Larger bundle size and potentially slower initial load time
- Less frequently updated compared to GraphiQL
- May have a steeper learning curve for beginners
Code Comparison
GraphiQL:
import { GraphiQL } from 'graphiql';
function App() {
return <GraphiQL fetcher={customFetcher} />;
}
GraphQL Playground:
import { Playground } from 'graphql-playground-react';
function App() {
return <Playground endpoint="https://api.example.com/graphql" />;
}
Both GraphiQL and GraphQL Playground are popular GraphQL IDEs, but they have different focuses. GraphiQL is more lightweight and frequently updated, making it ideal for quick integration and development. GraphQL Playground offers a richer feature set, including better support for complex operations and team collaboration.
GraphiQL is maintained directly by the GraphQL Foundation, ensuring close alignment with GraphQL specifications. GraphQL Playground, while powerful, has seen less frequent updates in recent years.
Ultimately, the choice between these tools depends on specific project requirements, team preferences, and the complexity of GraphQL operations being performed.
A reference implementation of GraphQL for JavaScript
Pros of graphql-js
- Provides a complete GraphQL implementation in JavaScript
- Offers more flexibility for custom GraphQL server implementations
- Suitable for both server-side and client-side GraphQL processing
Cons of graphql-js
- Requires more setup and configuration compared to GraphiQL
- Steeper learning curve for developers new to GraphQL
- Less user-friendly for quick GraphQL query testing and exploration
Code Comparison
GraphiQL (React component usage):
import { GraphiQL } from 'graphiql';
function MyComponent() {
return <GraphiQL fetcher={customFetcher} />;
}
graphql-js (Schema definition):
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
hello: {
type: GraphQLString,
resolve() {
return 'Hello, world!';
},
},
},
}),
});
Summary
GraphiQL is an interactive in-browser GraphQL IDE, primarily used for exploring and testing GraphQL APIs. It provides a user-friendly interface for writing and executing queries, with features like auto-completion and documentation browsing.
On the other hand, graphql-js is a reference implementation of GraphQL in JavaScript. It offers a complete set of tools for building GraphQL schemas, executing queries, and integrating GraphQL into JavaScript applications. While more complex to set up, it provides greater flexibility and control over the GraphQL implementation.
:rocket: A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
Pros of Apollo Client
- More comprehensive client-side state management with caching and local state
- Extensive ecosystem with additional tools and integrations
- Better support for real-time updates and subscriptions
Cons of Apollo Client
- Steeper learning curve due to more complex API and features
- Potentially larger bundle size for smaller applications
- More opinionated approach, which may not suit all project structures
Code Comparison
GraphiQL (query execution):
const response = await fetch('/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: '{ hello }' }),
});
const result = await response.json();
Apollo Client (query execution):
const { data } = await client.query({
query: gql`
query {
hello
}
`
});
Summary
GraphiQL is primarily an in-browser IDE for exploring and testing GraphQL APIs, while Apollo Client is a full-featured state management library for building GraphQL applications. GraphiQL is simpler and more focused on API exploration, whereas Apollo Client offers more robust features for client-side data management and integration with application frameworks.
GraphiQL is better suited for API development and testing, while Apollo Client excels in building complex GraphQL-powered applications with advanced state management needs. The choice between the two depends on the specific requirements of your project and the level of GraphQL integration needed in your application.
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Pros of GraphQL Engine
- Full-featured GraphQL server with built-in authorization and database integration
- Automatic CRUD API generation from database schema
- Real-time subscriptions and event triggers
Cons of GraphQL Engine
- Steeper learning curve due to more complex architecture
- Tighter coupling with specific database technologies (primarily PostgreSQL)
- Potentially overkill for simpler GraphQL API needs
Code Comparison
GraphiQL (React component for GraphQL IDE):
import { GraphiQL } from 'graphiql';
function CustomGraphiQL() {
return <GraphiQL fetcher={customFetcher} />;
}
GraphQL Engine (Hasura configuration):
version: 2
tables:
- table:
schema: public
name: users
insert_permissions:
- role: user
permission:
check: {}
columns:
- name
- email
GraphiQL is a lightweight, frontend-focused tool for exploring and testing GraphQL APIs. It's ideal for developers who need a simple interface to interact with existing GraphQL endpoints.
GraphQL Engine, on the other hand, is a comprehensive backend solution that generates GraphQL APIs from database schemas. It offers more advanced features like authorization and real-time subscriptions but requires more setup and configuration.
Choose GraphiQL for a quick, flexible GraphQL IDE, or GraphQL Engine for a full-featured GraphQL server with database integration and advanced capabilities.
Code-First, Type-Safe, GraphQL Schema Construction
Pros of Nexus
- Provides a code-first approach to GraphQL schema development
- Offers powerful type generation and autocomplete features
- Includes a plugin system for extending functionality
Cons of Nexus
- Steeper learning curve for developers new to code-first GraphQL
- Less suitable for exploring existing GraphQL APIs
- Requires additional setup compared to GraphiQL
Code Comparison
GraphiQL (query explorer):
query {
user(id: "123") {
name
email
}
}
Nexus (schema definition):
const User = objectType({
name: 'User',
definition(t) {
t.string('name')
t.string('email')
},
})
Key Differences
- GraphiQL is an in-browser IDE for exploring and testing GraphQL APIs
- Nexus is a library for building GraphQL schemas in TypeScript/JavaScript
- GraphiQL focuses on query execution and API exploration
- Nexus emphasizes type-safe schema development and code generation
Use Cases
- GraphiQL: API testing, documentation, and exploration
- Nexus: Building robust, type-safe GraphQL servers and schemas
Community and Ecosystem
- GraphiQL: Widely adopted, part of the official GraphQL Foundation
- Nexus: Growing community, strong integration with TypeScript ecosystem
Awesome list of GraphQL
Pros of awesome-graphql
- Comprehensive collection of GraphQL resources, tools, and libraries
- Regularly updated with community contributions
- Covers a wide range of GraphQL-related topics and ecosystems
Cons of awesome-graphql
- Not an interactive tool or development environment
- Lacks hands-on GraphQL query execution capabilities
- May require additional effort to find specific information within the extensive list
Code comparison
While a direct code comparison isn't relevant due to the nature of these repositories, here's a brief example of how they might be used:
awesome-graphql:
## Tools
- [GraphiQL](https://github.com/graphql/graphiql) - An in-browser IDE for exploring GraphQL.
GraphiQL:
import { GraphiQL } from 'graphiql';
import 'graphiql/graphiql.min.css';
<GraphiQL fetcher={fetcher} />
Summary
awesome-graphql serves as a comprehensive resource hub for GraphQL-related information, while GraphiQL is an interactive in-browser IDE for exploring and testing GraphQL queries. awesome-graphql provides a broader overview of the GraphQL ecosystem, but lacks the hands-on functionality offered by GraphiQL. GraphiQL, on the other hand, focuses on providing a practical development environment for working with GraphQL APIs.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
GraphQL IDE Monorepo
Security Notice: All versions of
graphiql
<1.4.7
are vulnerable to an XSS attack in cases where the GraphQL server to which the GraphiQL web app connects is not trusted. Learn more in the graphiqlsecurity
docs directory
Looking for the GraphiQL Docs?: This is the root of the monorepo! The full GraphiQL docs are located at
packages/graphiql
Overview
GraphiQL is the reference implementation of this monorepo, GraphQL IDE, an official project under the GraphQL Foundation. The code uses the permissive MIT license.
Whether you want a simple GraphiQL IDE instance for your server, or a more advanced web or desktop GraphQL IDE experience for your framework or plugin, or you want to build an IDE extension or plugin, you've come to the right place!
The purpose of this monorepo is to give the GraphQL Community:
- a to-specification official language service (see: API Docs)
- a comprehensive LSP server and CLI service for use with IDEs
- a codemirror mode
- a monaco mode (in the works)
- an example of how to use this ecosystem with GraphiQL.
- examples of how to implement or extend GraphiQL.
graphiql
/ËÉ¡rafÉk(É)l/ A graphical interactive in-browser GraphQL IDE.
Try the live demo. We also have
a demo using our latest netlify build for
the main
branch.
The GraphiQL IDE, implemented in React, currently using GraphQL mode for CodeMirror & GraphQL Language Service.
Learn more about
GraphiQL in packages/graphiql/README.md
monaco-graphql
Provides monaco editor with a powerful, schema-driven graphql language mode.
Uses the graphql-language-service
directly.
See the webpack example for a plain javascript demo using GitHub API
codemirror-graphql
Provides CodeMirror 5 with a parser mode for GraphQL along with a live linter and
typeahead hinter powered by your GraphQL Schema. Uses the
graphql-language-service
.
cm6-graphql
Provides CodeMirror 6 with a full-featured language mode for GraphQL. Uses the graphql-language-service
.
graphql-language-service
Provides language services for
graphql-language-service-server
codemirror-graphql
and
monaco-graphql
. Previously published separately as
the now-retired graphql-language-service-interface
,
graphql-language-service-parser
, graphql-language-service-utils
and
graphql-language-service-types
.
graphql-language-service-server
Provides language services for LSP-based IDE extensions using the
graphql-language-service
graphql.vscode-graphql
An example implementation of graphql-language-service-server
for Visual Studio
Code. Available
on the marketplace.
OVSX fix is pending.
graphql.vscode-graphql-syntax
A new syntax highlighting-only extension for vscode to be used by other vscode extensions.
graphql.vscode-graphql-execution
An extension for vscode-graphql that allows inline query execution.
graphql-language-service-cli
Provides a CLI for the language service server.
Browser & Runtime Support
Many of these packages need to work in multiple environments.
By default, all typescript packages target es6
.
graphql-language-service-server
and graphql-language-service-cli
are made
for the node runtime, so they target es2017
codemirror-graphql
and the graphiql
browser bundle use the
.browserslistrc
, which targets modern browsers to keep
bundle size small and keep the language services performant where async/await is
used, and especially to avoid the requirement of regenerator-runtime
or
special babel configuration.
.browserslistrc
:
last 2 versions
Firefox ESR
not dead
not IE 11
not ios 10
maintained node versions
To be clear, we do not support Internet Explorer or older versions of evergreen browsers.
Development
To get setup for local development of this monorepo, refer to DEVELOPMENT.md
Contributing to this repo
This is an open source project, and we welcome contributions. Please see CONTRIBUTING.md for details on how to contribute.
This repository is managed by EasyCLA. Project participants must sign the free GraphQL Specification Membership agreement before making a contribution. You only need to do this one time, and it can be signed by individual contributors or their employers.
To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.
Please note that EasyCLA is configured to accept commits from certain GitHub bots. These are approved on an exception basis once we are confident that any content they create is either unlikely to consist of copyrightable content or else was written by someone who has already signed the CLA (e.g., a project maintainer). The bots that have currently been approved as exceptions are:
- github-actions (exclusively for the
changesets
Action)
You can find detailed information here. If you have issues, please email operations@graphql.org.
Maintainers
Maintainers of this repository regularly review PRs and issues and help advance the GraphiQL roadmap
Alumni
Without these amazing past maintainers, where would we be?!
- @leebyron - original author of all libraries
- @asiandrummer - original creator of GraphiQL
- @wincent - early co-author and maintainer
- @lostplan - maintained the language service ecosystem until about 2017
- @IvanGoncharov - maintainer and transitional mentor to @acao and others
- @orta - has helped with so many parts of the project over the years, and provided the original redesign!
- @divyenduz - the original creator of
vscode-graphql
, and contributor to much of the ecosystem. Thanks Divy!
Active
Maintainers who are currently active (to varying degrees, please contact us via our discord channels!):
- @imolorhe
- @yoshiakis
- @urigo
- @timsuchanek
- @thomasheyenbrock
- @n1ru4l
- @acao
- @stonexer
- @B2o5T
- @dotansimha
- @saihaj
- @jonathanawesome
- @cshaver
Thank you graphql community for all the help & support! I did it all for you, and I couldn't have done it without you â¤ï¸ - @acao
Fielding Proposals!
The door is open for proposals for the new GraphiQL Plugin API, and other ideas
on how to make the rest of the IDE ecosystem more performant, scalable,
interoperable and extensible. Feel free to open a PR to create a document in the
/proposals/
directory. Eventually we hope to move these to a repo that serves
this purpose.
Community
- Discord - Most discussion outside of GitHub happens on the GraphQL Discord Server
- Twitter - @GraphiQL and #GraphiQL
- GitHub - Create feature requests, discussions issues and bugs above
- Working Group - Yes, you're invited! Monthly planning/decision making meetings, and working sessions every two weeks on zoom! Learn more.
Top Related Projects
🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
A reference implementation of GraphQL for JavaScript
:rocket: A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Code-First, Type-Safe, GraphQL Schema Construction
Awesome list of GraphQL
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot