Coder Social home page Coder Social logo

target / graphql-liftoff Goto Github PK

View Code? Open in Web Editor NEW
44.0 10.0 6.0 285 KB

Generate GraphQL schema language from API specifications and more

License: MIT License

JavaScript 43.64% TypeScript 56.36%
graphql liftoff schema definition type generator swagger

graphql-liftoff's Introduction

GraphQL Liftoff

license travis Coverage Status release watch star twitter

graphql-liftoff is a GraphQL schema type generator. It takes in an existing data model and maps it to type definitions by using a domain specific parser. This reduces the amount of work needed to migrate existing REST APIs to GraphQL.

CLI Demo

demo YAML source graphql-liftoff demo

Roadmap

  • Swagger 2.0 support
  • 100% unit test code coverage
  • CLI integration tests
  • TypeDoc comments on all functions
  • Swagger 1.0 support
  • OpenAPI (Swagger 3.0) support
  • RAML 1.0 support
  • Your idea here!

Quick start

# CLI utility
npm install -g git+https://github.com/target/graphql-liftoff.git
yarn global add git+https://github.com/target/graphql-liftoff.git

# npm package
npm install git+https://github.com/target/graphql-liftoff.git
yarn add git+https://github.com/target/graphql-liftoff.git

# development
Fork this repo
git clone https://github.com/YourName/graphql-liftoff.git
cd graphql-liftoff
npm install or yarn

# scripts
build        # run typescript compiler
watch        # watch on file changes - then run typescript compiler
start <args> # run graphql-liftoff CLI locally
             # NOTE: npm strips out flags like -y or --yaml
             # yarn works as intended.
             # you can still manually run the commands:
             # node ./build/bin/cli.js <args>
lint         # run tslint
test         # run jest and generate coverage files
test:watch   # watch on file chages - then run jest
coverage     # open html coverage in browser (MacOS only)

Module Usage

graphql-liftoff exports an async generateSchema function, which returns a stringified Graphql Schema

await generateSchema('swagger', {'yaml': true, data: './example-swagger.yaml'}).then(schema => {
    console.log(schema)
}).catch(err => {
    console.error(err)
})

Bugs and Feature Requests

Found something that doesn't seem right or have a feature request? First, checkout our contribution guidelines, then open a new issue.

Contributors

A huge shoutout to all contributors and supporters of this project. THANK YOU!

StephenRadachy Piefayth timrs2998

Copyright and License

license

Copyright (c) 2017 Target Brands, Inc.

graphql-liftoff's People

Contributors

jimthedev avatar piefayth avatar stephenradachy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-liftoff's Issues

Refactor Swagger CLI

Refactor Swagger CLI

Details

Since there is the goal of adding v1 v2 v3 support, instead of versioning out each Swagger instance, it's possible to refactor the existing swagger cli tool and identify the Swagger Version from the yaml/json file in order to determine which parser to use?

Additional Information

Essentially it would change the cli to only have a single swagger command, and the json/yaml file would dictate which parser to use inside of the service.

Issue Checklist

  • Maintainer has viewed
  • Loaded into Backlog
  • PR submitted [Link Here](Eventual Link)

Add parameter to allow for prefixing all generated types

Please Add parameter to allow for prefixing all generated types

We are looking at using graphql-liftoff in conjunction with schema stitching from multiple swagger files and have some type naming collisions occurring. i.e. ...system1/api/user & system2/api/user in two separate swagger files both generate a User typeDef. We would like to suggest an optional parameter be added that allows for prefixing resulting generated typeDefs to prevent these collisions

installation fail on OSX High Sierra

Details

cannot install on OSX High Sierra

Additional Information

yarn global add git+https://github.com/target/graphql-liftoff.git
yarn global v1.9.4
warning package.json: No license field
[1/4] ๐Ÿ”  Resolving packages...
warning git+https://github.com/target/graphql-liftoff.git > oas-raml-converter > raml-1-parser > [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning "git+https://github.com/target/graphql-liftoff.git > [email protected]" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
error /Users/shachar/.config/yarn/global/node_modules/graphql-liftoff: Command failed.
Exit code: 127
Command: node_modules/typescript/bin/tsc
Arguments: 
Directory: /Users/shachar/.config/yarn/global/node_modules/graphql-liftoff
Output:
/bin/sh: node_modules/typescript/bin/tsc: No such file or directory
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

seems related to typesafe pre-requisite which i do not have.

Issue Checklist

  • Maintainer has viewed

Change in description comments to be string literals per GraphQL spec.

Change in description comments to be string literals per GraphQL spec.

Details

Per the spec in GraphQL code base:
/**

  • Descriptions are defined as preceding string literals, however an older
  • experimental version of the SDL supported preceding comments as
  • descriptions. Set to true to enable this deprecated behavior.
  • This option is provided to ease adoption and will be removed in v16.
  • Default: false
    */

All description comments should be encapsulated around string literals, more specifically triple double quotes:
""" Description here """

Additional Information

I used your package to convert a swagger file from a third party API and there are a few things that needed to be done. This package does not recheck the return gql for malformations. I had to scan through the file and check to see if there was multi-line 'comments' and to rebuild it accordingly.

Link to comment in code base:
extendSchema#L47

Issue Checklist

  • Maintainer has viewed
  • Loaded into Backlog
  • PR submitted [Link Here](Eventual Link)

wait

graphql-liftoff issue template replace with your issue title

Details

Provide a general statement here about the feature/bug/request
you have here

Additional Information

Provide any supporting documentation here. (Links to wiki, other sources, log output, etc.)

Issue Checklist

  • Maintainer has viewed
  • Loaded into Backlog
  • PR submitted [Link Here](Eventual Link)

Beef up documentation

  • Add more information about how to make a parser
  • Provide more insight into where such a tool like this has value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.