vkolgi / json-to-graphql-query

Simple module that converts JavaScript objects to GraphQL query syntax
MIT License
283 stars 39 forks source link

Allow full inline fragments #21

Closed bconnorwhite closed 4 years ago

bconnorwhite commented 4 years ago

This allows for:

{
  query: {
    Posts: {
      __on: "Fragment"
    }
  }
}

To transform to:

query {
  Posts {
    ... Fragment
  }
}
dupski commented 4 years ago

Nice, thanks @ConnorWhite

Could you add a test for this in https://github.com/dupski/json-to-graphql-query/blob/master/src/__tests__/fragments.tests.ts please when you have a moment and I will look into merging it asap :)

bconnorwhite commented 4 years ago

Sure, just added a test @dupski.

Isos9 commented 4 years ago

Hi, is it possible to merge it @dupski ?

dupski commented 4 years ago

Yep, I was going to do it at the weekend then work stuff came up, sorry. Will be in the next few days, promise! :)

dupski commented 4 years ago

Hey man, just published v2.0.0 which includes support for full fragments. Changed the API slightly to __all_on: ["Fragment1", "Fragment2"] to allow for multiple full fragments :)