Giter VIP home page Giter VIP logo

graphql-parser's Introduction

GraphQL-Parser

A simple GraphQL parser written in C++. This parser can parse GraphQL queries and convert them to JSON.

Features

  • Parsing GraphQL queries
  • Converting GraphQL queries to JSON
  • Handling errors
  • Handling nested queries
  • Handling variables

Requirements

  • C++11 compiler
  • nlohmann/json library

Installation

git clone https://github.com/Bhavyyadav25/GraphQL-Parser.git cd GraphQL-Parser cmake . make

Usage

  1. Put your GraphQL query in query.graphql.

  2. Compile the parser by running the following command:

g++ graphql.cc -o <graphql>
  • You can put any name for the build file, and replace <graphql> with the name of your build file.
  1. Run the build file by running the following command:
./graphql
  • This will parse the GraphQL query in query.graphql and print the JSON representation of the query to the console.

Example

query {
  getTask(id: "0x3") {
    id
    title
    completed
  }
  getUser(username: "dgraphlabs") {
    username
  }
}

This is a valid GraphQL query that can be parsed by the parser. The output of the parser will be the following JSON:

{
  "JSON": [
    {
      "JSON": [
        {
          "name": "id"
        },
        {
          "name": "title"
        },
        {
          "name": "completed"
        }
      ],
      "name": "getTask"
    },
    {
      "JSON": [
        {
          "name": "username"
        }
      ],
      "name": "getUser"
    }
  ],
  "name": "query"
}

Documentation

The documentation for the parser can be found in the README.md.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.

License

The parser is licensed under the MIT License. See the LICENSE: MIT

graphql-parser's People

Watchers

Bhavy Yadav avatar

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.