Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add inline fragments support #55

Closed
andriy-sermiahin opened this issue Mar 18, 2021 · 10 comments
Closed

[FEATURE] Add inline fragments support #55

andriy-sermiahin opened this issue Mar 18, 2021 · 10 comments
Assignees
Milestone

Comments

@andriy-sermiahin
Copy link

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.

@khaosdoctor
Copy link
Owner

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.

@khaosdoctor khaosdoctor self-assigned this Mar 18, 2021
@khaosdoctor khaosdoctor added this to the v3 milestone Mar 18, 2021
@AndriiPitsyk
Copy link

AndriiPitsyk commented Mar 19, 2021

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

@khaosdoctor
Copy link
Owner

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 :)

@andriy-sermiahin
Copy link
Author

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

@khaosdoctor
Copy link
Owner

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

@khaosdoctor
Copy link
Owner

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.

@koolamusic
Copy link

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

@khaosdoctor
Copy link
Owner

khaosdoctor commented May 25, 2021

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?

khaosdoctor added a commit that referenced this issue Jun 11, 2021
As requested by #55 this address a first approach to add the fragment support
@khaosdoctor
Copy link
Owner

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.

@khaosdoctor khaosdoctor added the hacktoberfest Good issue for Hacktoberfest label Oct 17, 2021
@khaosdoctor
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants