npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@catalystsquad/proto2graphql

v0.1.3-alpha

Published

Converts schema definitions in Protocol Buffer to GraphQL

Downloads

6

Readme

proto2graphql GitHub license npm version CircleCI Status Coverage Status

Converts schema definitions in Protocol Buffer (proto3) to GraphQL. Can be used to help generate a GraphQL API gateway to gRPC backend services.

Installation

npm install -g proto2graphql

Usage

proto2graphql --input [input .proto path] --output [output .graphql path]

Conversions

Messages

Protocol Buffer

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
}

GraphQL

type SearchRequest {
  query: String
  pageNumber: Int
  resultPerPage: Int
}

Scalar Value Types

| Protocol Buffer | GraphQL | | --------------: | ------: | | double | Float | | float | Float | | int32 | Int | | int64 | Int | | uint32 | Int | | uint64 | Int | | sint32 | Int | | sint64 | Int | | fixed32 | Int | | fixed64 | Int | | sfixed32 | Int | | sfixed64 | Int | | bool | Boolean | | string | String | | bytes | String |

Enumerations

Protocol Buffer

enum Corpus {
  UNIVERSAL = 0;
  WEB = 1;
  IMAGES = 2;
  LOCAL = 3;
  NEWS = 4;
  PRODUCTS = 5;
  VIDEO = 6;
}

GraphQL

enum Corpus {
  UNIVERSAL
  WEB
  IMAGES
  LOCAL
  NEWS
  PRODUCTS
  VIDEO
}

Nested Types

Protocol Buffer

message SearchResponse {
  message Result {
    string url = 1;
    string title = 2;
  }
  Result result = 1;
}

GraphQL

type SearchResponse {
  results: SearchResponse_Result
}

type SearchResponse_Result {
  url: String
  title: String
}

Oneof

Protocol Buffer

message UserAuth {
  message GoogleProvider {
    int32 gid = 1;
  }

  message FacebookProvider {
    string fbid = 1;
  }

  oneof provider {
    GoogleProvider google = 1;
    FacebookProvider facebook = 2;
    string generic = 3;
  }
}

GraphQL

type UserAuth {
  provider: UserAuth_provider
}

union UserAuth_provider =
    UserAuth_GoogleProvider
  | UserAuth_FacebookProvider
  | String

type UserAuth_GoogleProvider {
  gid: Int
}

type UserAuth_FacebookProvider {
  fbid: String
}

Maps

Protocol Buffer

message User {
  map<string, Attribute> attributes = 1;
}

message Attribute {
  string value = 1;
}

GraphQL

type User {
  attributes: [String_Attribute_map]
}

type String_Attribute_map {
  key: String
  value: Attribute
}

type Attribute {
  value: String
}

Packages

Protocol Buffer

package proto2graphql.common;

message TypeA {
  int32 field = 1;
}

GraphQL

type proto2graphql_common_TypeA {
  field: Int
}

Well-Known Types

Protocol Buffer

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

message WellKnownTypes {
  google.protobuf.Duration duration_field = 1;
  google.protobuf.Timestamp timestamp_field = 2;
}

GraphQL

type WellKnownTypes {
  durationField: google_protobuf_Duration
  timestampField: google_protobuf_Timestamp
}

type google_protobuf_Duration {
  seconds: Int
  nanos: Int
}

type google_protobuf_Timestamp {
  seconds: Int
  nanos: Int
}