Registry / testing / grpc-graphql-schema-example

grpc-graphql-schema-example

JSON →
library0.0.14-alpha-45c76fe.0jsnpmunverified

An example project demonstrating how to automatically generate a GraphQL schema from gRPC service definitions. Version 0.0.14-alpha, built on commit 45c76fe, likely part of a larger toolchain (e.g., grpc-graphql-schema). No stable release; unmaintained since 2019. Key differentiator: auto-generates GraphQL schema and resolvers from protobuf, allowing GraphQL queries over gRPC backends without manual schema writing. However, it is an alpha example and not suitable for production.

npm install grpc-graphql-schema-example
INSTALL
IMPORT
SIG · GRPC-GRAPHQL-SCHEM
G
grpc-graphql-schema-example
testingjavascriptv0.0.14-alpha-45c76fe.0
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.

GrpcGraphQLSchema
import { GrpcGraphQLSchema } from 'grpc-graphql-schema'
import GrpcGraphQLSchema from 'grpc-graphql-schema'
Named export; default import is not available.
grpc
import grpc from 'grpc'
import { grpc } from 'grpc'
gRPC-js v1.20+ uses default export; named export is a common mistake.
loadSync
import { loadSync } from '@grpc/proto-loader'
import { loadSync } from 'grpc'
Proto loading is separate from grpc package since gRPC v1.24.

This example shows how to load a protobuf file, create a gRPC client, generate a GraphQL schema using grpc-graphql-schema, and output the schema.

const grpc = require('grpc'); const { GrpcGraphQLSchema } = require('grpc-graphql-schema'); const { loadSync } = require('@grpc/proto-loader'); const { parse } = require('graphql'); const packageDefinition = loadSync('./helloworld.proto'); const grpcObject = grpc.loadPackageDefinition(packageDefinition); const schema = new GrpcGraphQLSchema({ proto: './helloworld.proto', address: 'localhost:50051' }); async function main() { const graphqlSchema = await schema.generateSchema(); const typeDefs = parse(graphqlSchema); console.log(JSON.stringify(typeDefs)); } main().catch(console.error);
Debug
Known issues
deprecatedThe 'grpc' package is deprecated in favor of '@grpc/grpc-js'.
fix
Replace 'grpc' with '@grpc/grpc-js' in imports and dependencies.
affects: >=1.24
breakinggrpc-graphql-schema-example is an alpha example and has not been updated since 2019. APIs may have changed in the parent package.
fix
Reference the latest stable version of grpc-graphql-schema for production use.
affects: 0.0.14-alpha
gotchaThe generated GraphQL schema might not include all gRPC methods if the proto file uses advanced features like streaming.
fix
Ensure the proto file uses unary RPCs for full compatibility.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'grpc'
grpc is not installed or is deprecated.
fix
npm install @grpc/grpc-js and replace 'grpc' with '@grpc/grpc-js'.
Error: Cannot find module 'grpc-graphql-schema'
grpc-graphql-schema is not installed.
fix
npm install grpc-graphql-schema
TypeError: GrpcGraphQLSchema is not a constructor
Default import used instead of named import.
fix
Use import { GrpcGraphQLSchema } from 'grpc-graphql-schema'
Upgrade
Version history
0.0.14-alpha-45c76fe.0latest on npm
Audit
Dependencies
grpc-graphql-schemarequiredCore package for generating GraphQL schema from gRPC definitions
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-graphql-schema-example — npm install grpc-graphql-schema-example · libregistry