All Projects → walmartlabs → Json To Simple Graphql Schema

walmartlabs / Json To Simple Graphql Schema

Licence: other
Transforms JSON input into a GraphQL schema

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Json To Simple Graphql Schema

Dotnet Fake Json Server
Fake JSON Server is a Fake REST API that can be used as a Back End for prototyping or as a template for a CRUD Back End.
Stars: ✭ 265 (+43.24%)
Mutual labels:  graphql, json
Stash
An organizer for your porn, written in Go
Stars: ✭ 591 (+219.46%)
Mutual labels:  graphql, json
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (+1.62%)
Mutual labels:  graphql, json
Quicktype
Generate types and converters from JSON, Schema, and GraphQL
Stars: ✭ 7,459 (+3931.89%)
Mutual labels:  graphql, json
Prettier
Prettier is an opinionated code formatter.
Stars: ✭ 41,411 (+22284.32%)
Mutual labels:  graphql, json
Json Serverless
Transform a JSON file into a serverless REST API in AWS cloud
Stars: ✭ 108 (-41.62%)
Mutual labels:  graphql, json
Jseg
A super simple, in-memory, JS graph database.
Stars: ✭ 344 (+85.95%)
Mutual labels:  graphql, json
Manifold
Manifold plugs into Java to supplement it with powerful features, from Type-safe Metaprogramming (direct access to GraphQL, JSON, XML, etc.), Extension Methods, Operator Overloading, and Unit Expressions to an integrated Template Engine and a Preprocessor. All fully supported in IntelliJ IDEA and Android Studio. Simply add Manifold to your project and begin taking advantage of it.
Stars: ✭ 993 (+436.76%)
Mutual labels:  graphql, json
Graphql Factory
A toolkit for building GraphQL
Stars: ✭ 44 (-76.22%)
Mutual labels:  graphql, json
Persianjsonplaceholder
Persian fake REST/GraphQL API for testing and prototyping.
Stars: ✭ 110 (-40.54%)
Mutual labels:  graphql, json
Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-26.49%)
Mutual labels:  graphql, json
Stubbornjava
Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.
Stars: ✭ 184 (-0.54%)
Mutual labels:  json
Feed Module
Everyone deserves RSS, ATOM and JSON feeds!
Stars: ✭ 182 (-1.62%)
Mutual labels:  json
Gqlify
[NOT MAINTAINED]An API integration framework using GraphQL
Stars: ✭ 182 (-1.62%)
Mutual labels:  graphql
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (-2.16%)
Mutual labels:  graphql
Smakosh.com
My personal website
Stars: ✭ 185 (+0%)
Mutual labels:  graphql
Prisma Auth0 Example
Boilerplate Prisma Startup
Stars: ✭ 184 (-0.54%)
Mutual labels:  graphql
Circe
Yet another JSON library for Scala
Stars: ✭ 2,223 (+1101.62%)
Mutual labels:  json
Transform
A polyglot web converter.
Stars: ✭ 2,842 (+1436.22%)
Mutual labels:  graphql
Json C
https://github.com/json-c/json-c is the official code repository for json-c. See the wiki for release tarballs for download. API docs at http://json-c.github.io/json-c/
Stars: ✭ 2,313 (+1150.27%)
Mutual labels:  json

json-to-simple-graphql-schema

Transforms JSON input into a GraphQL schema. Try it here

Why would I use this?

Let's say you want to use an existing REST API in a GraphQL service and expose the data that API provides. You'll need to expose that data in a GraphQL schema. Without this tool, you'll have to slog through the JSON response and manually extract and convert the relevant types to GraphQL schema types. This tool attempts to provide an automated reasonable first-pass at that effort.

Installation:

For use as a command-line app use npx :) If you'd really like to install, you can do:

npm i -g @walmartlabs/json-to-simple-graphql-schema

For use in a project:

npm i @walmartlabs/json-to-simple-graphql-schema

Command Line Usage:

Pipe in some JSON. Here's a cURL JSON response piped in to this app:

curl "https://data.cityofnewyork.us/api/views/kku6-nxdu/rows.json?accessType=DOWNLOAD" \
| npx @walmartlabs/json-to-simple-graphql-schema

You'll still need to rename the resulting main Type in the schema, unless you like AutogeneratedMainType :)

Or pipe in some JSON from a JSON file.

curl https://data.cityofnewyork.us/api/views/kku6-nxdu/rows.json?accessType=DOWNLOAD > input.json

cat input.json | npx json-to-simple-graphql-schema > output.graphql

Optional parameters:

  • baseType = "AutogeneratedMainType"
  • prefix = ""
curl https://data.cityofnewyork.us/api/views/kku6-nxdu/rows.json?accessType=DOWNLOAD > input.json

cat input.json | npx json-to-simple-graphql-schema --baseType BaseType --prefix Prefix > output.graphql

Usage in front-end JS:

import { jsonToSchema } from "@walmartlabs/json-to-simple-graphql-schema/lib";

const schema = jsonToSchema({ jsonInput: '{"name": "Test"}' });
console.log(schema.value);

If you need more guidance, have a look at the source for our simple web-ui.

Example output:

Given this JSON:

{
  "id": "some-id-0",
  "name": "A fun object",
  "subType": {
    "id": "some-id-1",
    "name": "A fun sub-type"
  }
}

This app will send this to stdout:

type SubType { 
  id: String 
  name: String,
} 
type AutogeneratedMainType { 
  id: String 
  name: String 
  subType: SubType
}

Fun features: duplicate removal

Consider this JSON with 2 color types:

{
  "id": "some-id-0",
  "name": "A fun object",
  "color": {
    "id": "color-id-1",
    "name": "Test color"
  },
  "subType": {
    "id": "some-id-1",
    "name": "A fun sub-type",
    "color": {
      "id": "color-id-1",
      "name": "Test color",
      "hex": "#ff0000"
    }
  }
}

When piped to this app, the following schema is produced:

type Color { 
  id: String 
  name: String 
  hex: String,
} 
type SubType { 
  id: String 
  name: String 
  color: Color,
} 
type AutogeneratedMainType { 
  id: String 
  name: String 
  subType: SubType 
  color: Color
}

It kept the Color type with more fields.

Fun features: calls out possible duplicates

Consider this JSON with two types containing identical fields:

{
  "id": "some-id-0",
  "name": "A fun object",
  "color": {
    "id": "color-id-1",
    "name": "Test color"
  },
  "favoriteColor": {
    "id": "color-id-1",
    "name": "Test color"
  }
}

When piped to this app, the following schema is produced:

type FavoriteColor {
  id: String
  name: String
}

type Color {
  id: String
  name: String
}

type AutogeneratedMainType {
  id: String
  name: String
  favoriteColor: FavoriteColor
  color: Color
}

# Types with identical fields:
# FavoriteColor Color

It called out the two types with identical fields.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].