#!/bin/bash echo "=== GraphiQL Installation Script ===" if ! command -v node &> /dev/null; then echo "Node.js not found. Please install Node.js 16+" exit 1 fi Create project mkdir graphiql-demo && cd graphiql-demo npm init -y Install dependencies npm install express graphql graphql-http Create server file cat > server.js << 'EOF' const express = require('express'); const createHandler = require('graphql-http/lib/use/express'); const buildSchema = require('graphql');
await server.start();
| Requirement | Version | Notes | |-------------|---------|-------| | Node.js | 16.x or higher | Required for npm/yarn installations | | npm | 8.x or higher | or yarn, pnpm | | GraphQL Server | Any | Express, Apollo, Yoga, etc. | | Modern Browser | Latest | Chrome, Firefox, Edge | 3.1 Method 1: Express Middleware (Most Common) Target: Adding GraphiQL to an existing Express.js GraphQL server. Step-by-step: # Create project directory mkdir my-graphql-app && cd my-graphql-app Initialize npm project npm init -y Install required packages npm install express graphql graphql-http npm install graphql-express Server Setup ( server.js ): const express = require('express'); const createHandler = require('graphql-http/lib/use/express'); const buildSchema = require('graphql'); // Build schema const schema = buildSchema( type Query hello: String ); graphiql install
EXPOSE 3000
app.all('/graphql', createHandler( schema, rootValue: root )); | | Modern Browser | Latest | Chrome, Firefox, Edge | 3
;
const resolvers = Query: hello: () => 'Hello from Apollo!' const buildSchema = require('graphql')