{"id":47459,"library":"egg-graphql","title":"egg-graphql","description":"Egg.js plugin for integrating GraphQL using Apollo GraphQL Tools and GraphQL Server. Version 2.8.0 supports Egg.js applications with Node >=8.0.0. Provides automatic schema loading from app/graphql directory, integrated DataLoader, custom directives, and GraphiQL development tool. Enables GraphQL-first development by separating schema, resolvers, connectors, and models. Compared to manual GraphQL setup, this plugin offers seamless Egg.js integration with configuration-driven routing, middleware support, and Apollo Server options passthrough. Active maintenance by the Egg.js team.","status":"active","version":"2.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/eggjs/egg-graphql","tags":["javascript","egg","graphql","egg-plugin","eggPlugin","orm"],"install":[{"cmd":"npm install egg-graphql","lang":"bash","label":"npm"},{"cmd":"yarn add egg-graphql","lang":"bash","label":"yarn"},{"cmd":"pnpm add egg-graphql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for building GraphQL schema from schema strings and resolvers","package":"graphql-tools","optional":false},{"reason":"Provides the GraphQL server implementation to handle query parsing and execution","package":"graphql-server","optional":false},{"reason":"Used to batch and cache data fetching operations per request","package":"dataloader","optional":true}],"imports":[{"note":"egg-graphql is a plugin, not a direct require. It must be configured in config/plugin.js.","wrong":"const graphql = require('egg-graphql');","symbol":"graphql","correct":"// In config/plugin.js\nmodule.exports = {\n  graphql: {\n    enable: true,\n    package: 'egg-graphql',\n  },\n};"},{"note":"Middleware is registered via config.middleware array, not directly in app.js.","wrong":"app.use(require('egg-graphql'));","symbol":"graphql middleware","correct":"// In config/config.default.js\nmodule.exports = {\n  graphql: {\n    router: '/graphql',\n    app: true,\n    agent: false,\n    graphiql: true,\n  },\n  middleware: ['graphql'],\n};"},{"note":"Schema files must be placed in app/graphql subdirectories and use .graphql extension. Directly writing schemas in JavaScript with gql tag is not supported; use .graphql files.","wrong":"// Placing schema outside app/graphql\n// Using .js files with gql template literal (not supported)","symbol":"Schema files","correct":"// app/graphql/user/schema.graphql\ntype Query {\n  user(id: ID!): User\n}\ntype User {\n  id: ID!\n  name: String\n}"}],"quickstart":{"code":"// Install\n// npm i --save egg-graphql\n\n// config/plugin.js\nexports.graphql = {\n  enable: true,\n  package: 'egg-graphql',\n};\n\n// config/config.default.js\nexports.graphql = {\n  router: '/graphql',\n  app: true,\n  agent: false,\n  graphiql: true,\n};\nexports.middleware = ['graphql'];\n\n// app/graphql/query/schema.graphql\ntype Query {\n  hello: String\n}\n\n// app/graphql/query/resolver.js\nmodule.exports = {\n  Query: {\n    hello: () => 'Hello world',\n  },\n};\n\n// Start app and navigate to http://localhost:7001/graphql?query={hello}","lang":"javascript","description":"Shows minimal setup: install plugin, configure plugin and middleware, create schema and resolver, then query via browser."},"warnings":[{"fix":"Add graphql entry to config/plugin.js with enable: true and package: 'egg-graphql'.","message":"Plugin must be enabled in config/plugin.js, not just installed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add 'graphql' to exports.middleware in config.default.js.","message":"Middleware must be registered in config.middleware array, otherwise routes are not intercepted.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure file is named schema.graphql and located under app/graphql/<model>/.","message":"Schema files must use .graphql extension and be placed in app/graphql subdirectories.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use module.exports = { Query: { ... } } in resolver.js.","message":"Resolver functions must use module.exports, not ES6 exports.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.8.0':17 '8.0.0':23 'activ':74 'apollo':10,70 'app/graphql':29 'applic':20 'automat':25 'compar':51 'configur':64 'configuration-driven':63 'connector':48 'custom':33 'dataload':32 'develop':37,43 'direct':34 'directori':30 'driven':65 'egg':2,81,84 'egg-graphql':1 'egg-plugin':83 'egg.js':4,19,60,78 'eggplugin':86 'enabl':39 'first':42 'graphiql':36 'graphql':3,8,11,14,41,54,82 'graphql-first':40 'integr':7,31,61 'javascript':80 'load':27 'mainten':75 'manual':53 'middlewar':67 'model':50 'node':22 'offer':58 'option':72 'orm':87 'passthrough':73 'plugin':5,57,85 'provid':24 'resolv':47 'rout':66 'schema':26,46 'seamless':59 'separ':45 'server':15,71 'setup':55 'support':18,68 'team':79 'tool':12,38 'use':9 'version':16","created_at":"2026-06-07T16:51:37.823535+00:00","updated_at":"2026-06-07T16:51:37.823535+00:00","problems":[{"fix":"Ensure schema.graphql files exist under app/graphql/<model>/ and directories are lowercase.","cause":"Schema files missing or not in correct directory structure.","error":"GraphQL schema is not found / Cannot find module 'app/graphql'"},{"fix":"Add 'graphql' to exports.middleware in config.default.js and verify graphql config has router path.","cause":"Middleware not registered or graphql config missing.","error":"Router 'graphql' not found / 404 on /graphql"},{"fix":"Export an object with top-level Query/Mutation keys: module.exports = { Query: { ... } }.","cause":"Resolver file exports wrong structure or not loaded.","error":"TypeError: Cannot read property 'Query' of undefined"}],"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/eggjs/egg-graphql#readme","github":"https://github.com/eggjs/egg-graphql","docs":null,"changelog":null,"pypi":null,"npm":"egg-graphql","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}}