{"id":47982,"library":"graphql2rest","title":"GraphQL2REST","description":"Automatically generate a RESTful API from your existing GraphQL API. This Node.js library reads your GraphQL schema and a user-provided manifest file to generate an Express router with fully RESTful HTTP routes. v1.0.1 is the current stable version, released under MIT license by Sisense. Key differentiators: supports any GraphQL server execution function, customizable endpoints mapping, and allows you to have both GraphQL and REST APIs from a single schema with full control over REST configuration.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/sisense/graphql2rest","tags":["javascript","graphql","rest","api","graphql2rest","restful","graphql-to-rest"],"install":[{"cmd":"npm install graphql2rest","lang":"bash","label":"npm"},{"cmd":"yarn add graphql2rest","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql2rest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Generates Express router for RESTful routes","package":"express","optional":false}],"imports":[{"note":"ESM-only since v1.0.0, no CommonJS support.","wrong":"const GraphQL2REST = require('graphql2rest');","symbol":"GraphQL2REST","correct":"import GraphQL2REST from 'graphql2rest';"},{"note":"Type imported for TypeScript type checking.","symbol":"type GraphQL2RESTConfig","correct":"import type { GraphQL2RESTConfig } from 'graphql2rest';"},{"note":"Express must be used alongside graphql2rest. Both are ESM-only.","wrong":"const express = require('express');\nconst GraphQL2REST = require('graphql2rest');","symbol":"default (with express)","correct":"import express from 'express';\nimport GraphQL2REST from 'graphql2rest';"}],"quickstart":{"code":"import express from 'express';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport GraphQL2REST from 'graphql2rest';\nimport { execute } from 'graphql';\nimport { schema } from './myGraphQLSchema.js';\nimport { readFileSync } from 'fs';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst gqlGeneratorOutputFolder = path.resolve(__dirname, './gqlFilesFolder');\nconst manifestFile = path.resolve(__dirname, './manifest.json');\n\n// One-time pre-processing\nGraphQL2REST.generateGqlQueryFiles(schema, gqlGeneratorOutputFolder);\n\n// Initialize REST router\nconst restRouter = GraphQL2REST.init(schema, execute, { gqlGeneratorOutputFolder, manifestFile });\n\nconst app = express();\napp.use('/api', restRouter);\napp.listen(4000, () => {\n  console.log('REST API listening on port 4000');\n});","lang":"typescript","description":"Shows full setup: generate query files from schema, initialize router with manifest, and mount on Express app."},"warnings":[{"fix":"Ensure generateGqlQueryFiles is called first, typically as a build step or at startup before calling init.","message":"generateGqlQueryFiles must be called once before init, otherwise init will fail with missing files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use graphql's execute function or wrap your custom executor to match the standard signature.","message":"The execute function must match the signature expected by graphql2rest (standard GraphQL execute). Using a custom execute with different arguments will break.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use path.resolve(__dirname, 'manifest.json') to ensure correct path resolution.","message":"The manifest file path must be absolute or relative to process.cwd(), not relative to the script file.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pin to exact version in package.json and review changelog before upgrading.","message":"Version 1.0 is the first stable release; no deprecation warnings yet, but be aware future versions may change internal APIs.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'allow':60 'api':6,11,68,82 'automat':2 'configur':78 'control':75 'current':39 'customiz':56 'differenti':49 'endpoint':57 'execut':54 'exist':9 'express':29 'file':25 'full':74 'fulli':32 'function':55 'generat':3,27 'graphql':10,17,52,65,80,86 'graphql-to-rest':85 'graphql2rest':1,83 'http':34 'javascript':79 'key':48 'librari':14 'licens':45 'manifest':24 'map':58 'mit':44 'node.js':13 'provid':23 'read':15 'releas':42 'rest':5,33,67,77,81,84,88 'rout':35 'router':30 'schema':18,72 'server':53 'singl':71 'sisens':47 'stabl':40 'support':50 'user':22 'user-provid':21 'v1.0.1':36 'version':41","created_at":"2026-06-07T16:54:19.819572+00:00","updated_at":"2026-06-07T16:54:19.819572+00:00","problems":[{"fix":"Run 'npm install graphql2rest' and ensure your project uses ESM (type: module in package.json or .mjs extension).","cause":"Package not installed or import path incorrect.","error":"Error: Cannot find module 'graphql2rest'"},{"fix":"Replace 'const GraphQL2REST = require(\"graphql2rest\")' with 'import GraphQL2REST from \"graphql2rest\"'.","cause":"Incorrect import style (CommonJS require used instead of ESM import).","error":"TypeError: GraphQL2REST.generateGqlQueryFiles is not a function"},{"fix":"Call GraphQL2REST.generateGqlQueryFiles(schema, './gqlFilesFolder') before calling init, or create the folder manually.","cause":"generateGqlQueryFiles not called or output folder does not exist.","error":"Error: ENOENT: no such file or directory, open '.../gqlFilesFolder'"},{"fix":"Ensure manifest.json exists at the specified path and use absolute path with path.resolve(__dirname, 'manifest.json').","cause":"Manifest file path is incorrect or file missing.","error":"Error: Manifest file not found at path: ./manifest.json"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sisense/graphql2rest#readme","github":"https://github.com/sisense/graphql2rest","docs":null,"changelog":null,"pypi":null,"npm":"graphql2rest","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}