Registry / database / grpc-graphql-schema

grpc-graphql-schema

JSON →
library0.0.9jsnpmunverified

Converts gRPC protobuf service definitions into a GraphQL schema, enabling GraphQL servers to proxy requests to gRPC backends. Current version 0.0.9 is experimental with minimal maintenance. Unlike manual schema stitching or resolvers, this library auto-generates both type definitions and resolvers from .proto files. Requires gRPC endpoint and proto file path. Suitable for rapid prototyping but not production due to limited error handling and no streaming support.

npm install grpc-graphql-schema
INSTALL
IMPORT
SIG · GRPC-GRAPHQL-SCHEM
G
grpc-graphql-schema
databasejavascriptv0.0.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getGraphqlSchemaFromGrpc
const { getGraphqlSchemaFromGrpc } = require('grpc-graphql-schema');
import { getGraphqlSchemaFromGrpc } from 'grpc-graphql-schema';
Package is CJS only; ES import will fail with default Node.js.
default import
const ggs = require('grpc-graphql-schema');
import ggs from 'grpc-graphql-schema';
No default export; use destructuring or named require.
GraphQLSchema
// returned by getGraphqlSchemaFromGrpc
import { GraphQLSchema } from 'grpc-graphql-schema';
GraphQL types not exported; use 'graphql' package directly.

Shows how to load a gRPC proto file and create an Apollo GraphQL server proxying to gRPC.

const { getGraphqlSchemaFromGrpc } = require('grpc-graphql-schema'); const { ApolloServer } = require('apollo-server'); async function start() { const schema = await getGraphqlSchemaFromGrpc({ endpoint: 'localhost:50051', protoFilePath: '/path/to/ServiceDefinition.proto', serviceName: 'GrpcServiceName', packageName: 'name.package', }); const server = new ApolloServer({ schema }); server.listen(4000).then(() => console.log('GraphQL server on http://localhost:4000')); } start();
Debug
Known issues
gotchaProto file and gRPC endpoint must be accessible at runtime; wrong path or unavailable service crashes.
fix
Verify protoFilePath, endpoint, and ensure gRPC server is running before querying.
affects: >=0.0.1
gotchaOnly unary gRPC methods are supported; client/server streaming are not converted.
fix
Use alternative libraries like graphql-grpc for streaming support.
affects: >=0.0.1 <=0.0.9
deprecatedPackage has not been updated since 2019; may have vulnerabilities in gRPC dependency.
fix
Pin gRPC version manually or migrate to actively maintained alternatives.
affects: >=0.0.1
gotchaGraphQL field names are auto-generated from proto names; camelCase conversion may introduce naming collisions.
fix
Review generated schema and manually rename fields if needed using a schema transformation step.
affects: >=0.0.1
breakingIncorrect peer dependency on graphql ^14.0.2; incompatible with graphql@15 or newer.
fix
Use graphql@14 or override peer deps at own risk.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'grpc-graphql-schema'
Package not installed or npm install failed.
fix
Run 'npm install grpc-graphql-schema' and ensure node_modules contains it.
TypeError: getGraphqlSchemaFromGrpc is not a function
Using ES import syntax on a CJS module without default export.
fix
Change import to 'const { getGraphqlSchemaFromGrpc } = require('grpc-graphql-schema');'
Error: ENOENT: no such file or directory, open '/path/to/ServiceDefinition.proto'
Proto file path is incorrect or not found.
fix
Check protoFilePath points to an existing .proto file with read permissions.
Error: 14 UNAVAILABLE: failed to connect to all addresses
gRPC endpoint is not reachable or server not running.
fix
Ensure gRPC server is running on the specified endpoint and host is accessible.
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency for GraphQL schema definitions
Agent activity
6 hits · last 30 days
node
6
Resources
grpc-graphql-schema — npm install grpc-graphql-schema · libregistry