A simple GraphQL parser written in C++. This parser can parse GraphQL queries and convert them to JSON.
- Parsing GraphQL queries
- Converting GraphQL queries to JSON
- Handling errors
- Handling nested queries
- Handling variables
- C++11 compiler
- nlohmann/json library
git clone https://github.com/Bhavyyadav25/GraphQL-Parser.git cd GraphQL-Parser cmake . make
-
Put your GraphQL query in
query.graphql
. -
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.
- 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.
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"
}
The documentation for the parser can be found in the README.md.
Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.
The parser is licensed under the MIT License. See the LICENSE: MIT