Code Monkey home page Code Monkey logo

graphql-idl-parser's Introduction

graphql-idl-parser

A parser for GraphQL IDL files! This repository contains the code for both the Rust implementation, as well as the FFI dylib implementation, which allows you to generate a library for use in C projects (and other languages that play nice with C). See https://github.com/gjtorikian/graphql-idl-parser-ruby for a Ruby implementation!

Build Status

Why?

Two reasons:

  • I have plenty of experience doing Bison/LALR grammars in C, and I desperately wanted to learn some Rust.
  • Most of the GraphQL tooling, I'm sorry to say, appears to be in JavaScript. While that's cool, I really believe that when it comes to creating a tool ecosystem, base implementations ought to be in a language that can be consumed by other projects. In other words, the world doesn't need different GraphQL IDL parsers in Node, and Ruby, and Python, and Java, and Scala. The base format should be in something like C/C++/Rust, and then those higher level languages ought to make use of that one foundational library. This ensures consistency and correctness, no matter what your backend is written in.

Usage

Add this to your Cargo.toml:

[dependencies]
graphql-idl-parser = "^0.1"

and this to your crate root:

extern crate graphql_idl_parser;

After that, simply feed in a GraphQL IDL string to gqlidl::parse_schema, like:

let definitions = gqlidl::parse_schema(contents.as_str()).unwrap();
for def in definitions {
  // ...
}

Note that this library does not validate the format if your IDL. If you have multiple types with the same name, for example, they will be happily consumed as unique types. However, the parser will become irate if it comes across a malformed or unknown token.

Todo:

  • More documentation?
  • Support more of the IDL besides just types

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.