Coder Social home page Coder Social logo

trayio / graphql-query-to-json Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 10.0 259 KB

This is a simple module that takes a graphQL query string and converts it into a JSON object. Think of it as the reverse of the excellent module json-to-graphql-query.

License: MIT License

JavaScript 11.42% TypeScript 86.28% Shell 2.30%
developer-tools graphql json

graphql-query-to-json's People

Contributors

dependabot[bot] avatar jivemonkey avatar kingstray avatar snyk-bot avatar thomaschaplin avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-query-to-json's Issues

Query __args that are Integer value are not converting into integer

Scenarios: lets say we got query like this:

{
users (first: 1000, where: {showInFrontend: true}) { // first : 1000 is an integer value
edges {
node {
databaseId
}
}
}
}

the resulting argument object becomes:
args { first: '1000', where: { showInFrontend: true } } // this is incorrect as its meant to be IntValue

I did a modification to your code locally for now to fix it. The Fix:
In your getArguments and getArgumentObject function you also want to check the kind for IntValue like this eg in your getArguments function :
} else if (arg.value.kind === 'IntValue') { argsObj[arg.name.value] = parseInt(arg.value.value); {

I can do a PR if you want. Also thanks saved me hours of work trying to convert to Json ๐Ÿ‘

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.