mirror of
https://github.com/atulmy/gql-query-builder.git
synced 2026-04-25 23:55:55 +03:00
[GH-ISSUE #18] Fragments #10
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/gql-query-builder#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @iYaroslav on GitHub (Aug 5, 2019).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/18
Can I use fragments?
https://graphql.org/learn/queries/#fragments
@atulmy commented on GitHub (Aug 6, 2019):
At the moment it's not supported. If you think you can spare time to contribute, feel free to go ahead and send a pull request!
@toadkicker commented on GitHub (Aug 9, 2019):
The adapter is basically a bunch of fragments of template being assembled together. I don't see why one couldn't just write it such:
Then in the adapter class can just check if
fnNameexists, and call it when appropriate it.Just my quick thought/hack about it.
@atulmy commented on GitHub (Aug 14, 2019):
@iYaroslav you can follow @toadkicker's example until we bake in
Fragmentsout of the box.@toadkicker commented on GitHub (Aug 14, 2019):
I think to do that it would be helpful to have a bit of a formalized life cycle for an adapter that includes a better look at features like fragment injection.
@max-yilang commented on GitHub (Aug 19, 2019):
I would love to have this feature as well
@ARHariri commented on GitHub (Apr 2, 2020):
I don't see the purpose of using
Adapter(especially to handle fragment). When a user defines and passes an adapter as the second argument, he should write all logic of generating query instead of specifying his especial logic that should be replaced some parts of the default code, because of instantiating from user-defined adapter class and then pass the controller to that instance to handle all flow of generating a query.I think defining and using an adapter equals defining a new package to generate a GraphQL query.
So it seems using an adapter is not useful unless fixing adapter usage with one of the two following approaches:
1- Use
method overridingapproach of OOP (It seems the intention of using an adapter is this, but asDefaultQueryAdapteris not exposed, user should implement adapter from scratch)2- Accept function (or a config) as an adapter instead of class. In this way 1) highly recommended to follow the functional programming approach instead of OOP in the codebase and 2) get a config (instead of function) that defines logic to generate a query based on the passed options.
@IAmNatch commented on GitHub (Nov 26, 2020):
For Inline Fragments I found I was able to create the necessary queries by using dynamic object keys.
For example to generate the following query:
I wrote the following query:
This was great news for me. Thanks for building this awesome utility!