khaosdoctor / gotql

GraphQL query utility for serverside apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] Add inline fragments support

andriy-sermiahin opened this issue · comments

I have seen that there is a closed issue regarding adding graphql fragments support for v1.7.0 but I haven't found it in release notes or source code.
Could you implement such a feature for gotql or give an example of how to use it if I am wrong and gotql v2.* supports fragments?
We are using gotql for more than 6 months and it's already deeply implemented in our code to change it to something else.

Hey Andriy, thanks for submitting the issue.

The closed issue you saw was a feature that I intended to implement originally but then I dropped it in favor of more important ones and ended up never picking that up again. But I think it's time to review those since, as of today, GotQL does not implement fragment support.

This will be a pretty big change in the codebase, so it might take a while, but I think it makes sense to amplify the extension of the query language.

Hi @khaosdoctor

Could you provide some approximate date when we can expect new release version? We understand that it is open source tool and it might take time to prepare all thinks but we need to know approximate date to understand what we should do next( change the library or wait for release).

Thanks a lot that you are active owner of the current project!!

Since I'm working single-handed on this project, it might take about a month or so if I'm able to work without any hassle.

I think I can come up with something in two or three days of work, but I'll need to study the fragments and see how I can integrate those into the quer language spec.

If you have any ideas and/or suggestions on how this would work for you, I'd be glad to hear :)

Hi @khaosdoctor!
Any news regarding fragment functionality? :)

Hey @andriy-sermiahin I'm still working on it, I had a few health issues and I'm treating them first, but I'll try to release an alpha version of it by the end of the month.

This release will not count towards the latest releases but it'll be a start for you to begin using it

Hey @andriy-sermiahin I'm still working on it, I had a few health issues and I'm treating them first, but I'll try to release an alpha version of it by the end of the month.

This release will not count towards the latest releases but it'll be a start for you to begin using it

Ok people, sorry about the delay, I had some health issues and I was away for the month, still recovering, but I'll give it a go soon, I haven't forgotten about this.

It's alright @khaosdoctor please take your time and recover. anytime you are ready to work, you can get back. this work is always going to be here.

Thank you for all the hardwork put into this project @khaosdoctor

Alright folks I'm back o/ thanks a lot for your consideration and patience.

I'll work on this next week and try to get an alpha version out. I don't know if it's going to be what you are expecting because it requires some major changes to be officially "good". What I'm planning is to launch a v0 where you can define your fragments using string notation so I don't have to rewrite the entire parser.

V1 will be better integrated into the query language. Does it sound nice?

Hey! Just added the first fragment usage part. If you want to test it be sure to download @v2.1.1-alpha1.0

The added resources were:

  • You can add a new key in the query object called fragments it's a simple string array:
const query = {
  operation: {
    fields: [ 'f1' ]
  },
  fragments: [
	`fragment Test on Character { name id }`
  ]
}
  • You can use the literal fragment helper to add ... in front of your fields and nested fields like:
const query = {
  operation: {
    fields: [ fragment`Test` ]
  },
  fragments: [
	`fragment Test on Character { name id }`
  ]
}

For now, the query will not test for non existing fragments and it'll not test for invalid uses.

I should rewrite this module as a part of the query framework and the object framework when I free up some time to work on it. I also need to refactor some code because it's getting complicated to fiddle with it.

For hacktoberfest

This needs a good refactor, it's in the alpha version, support is limited, and it's a template string, it needs to be converted to a fully fledged JSON-like structure like the rest of the queries