insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

[Feature Request] Shared Fragments

Open hannahmshin opened this issue 5 years ago • 22 comments

Details

Would like a way to use common fragments in my queries without duplicating them in each request.

Related Issues

https://github.com/getinsomnia/insomnia/issues/1674 https://github.com/getinsomnia/insomnia/issues/1401

hannahmshin avatar Nov 14 '19 19:11 hannahmshin

👋 Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. If you're requesting a feature 🎁, please provide real use cases that would benefit. 👪

To help make this a smooth process, please be sure you have first read the contributing guidelines.

welcome[bot] avatar Nov 14 '19 19:11 welcome[bot]

Theres a pending open PR that solves this

elemanhillary-zz avatar Nov 15 '19 08:11 elemanhillary-zz

@elemanhillary Has that PR been merged? Thanks

djchen avatar Jan 24 '20 18:01 djchen

@elemanhillary any update on this?

xanderbuck avatar Mar 19 '20 20:03 xanderbuck

@elemanhillary What PR were you referring to? This would be a great feature to have!

briandiephuis avatar May 11 '20 10:05 briandiephuis

Could not find the pull request mentioned by @elemanhillary. This feature would make Insomnia so much more useful with GraphQL. It's terrible to keep fragments in sync when evolving an API.

kreutter avatar Jun 23 '20 15:06 kreutter

I am getting to a point I have to copy 2-4 fragment for each query. Adding shared fragments would really help

JaroVoltix avatar Nov 24 '20 02:11 JaroVoltix

Any chance of this in 2021? :D

MatthewCawley avatar Mar 01 '21 19:03 MatthewCawley

Would be very helpful 🙏🏻

Le-Polemil avatar Apr 14 '21 09:04 Le-Polemil

please save us from fragments-hell 😈

sa9sha9 avatar May 03 '21 16:05 sa9sha9

Give me a detailed example of this issue and i promise you in 2-3 weeks i will raise a PR for this issue @sa9sha9 @hannahmkim

elemanhillary-zz avatar May 03 '21 16:05 elemanhillary-zz

@elemanhillary

We want to be able to define a fragment in one place, but then use them on multiple requests.

Like environment variables for GraphQL queries.

Define this in a shared/central location

fragment taxFragment on Tax {
  taxId
  country
  region
  appliesToDigital
  taxAmount
}

Then allow it to be reused in multiple different requests

query utils_insomnia__taxes_app {
  taxes {
    ...taxFragment
  }
}

Because right now what I have to do is copy/paste the same fragments to the end of a zillion requests and if there is a change I have to go and update them all. Because graphql throws an error you can't just pass them all in, so Insomnia would have to have some level of intelligence. In my application code, I solve this by using templating language and I generate the queries. You could do something similar with supporting

query utils_insomnia__taxes_app {
  taxes {
    ...taxFragment
  }
}

${taxFragment}

@elemanhillary I will send you cookies if you make this happen and tell me where to send them!

RussBrown00 avatar May 15 '21 19:05 RussBrown00

We really need this feature

velidan avatar May 19 '21 08:05 velidan

Hey @elemanhillary! Any progress on this PR? We would love to be able to use this feature!

thonydam avatar May 21 '21 23:05 thonydam

Anybody figure out a good workaround?

pfcodes avatar Jun 08 '21 02:06 pfcodes

Any updates on this?

teroqim avatar Jun 09 '22 07:06 teroqim

I would also like this. Shared fragments is fundamental to clean and maintainable Graphql queries.

Alex-ray avatar Aug 18 '22 22:08 Alex-ray

Super hacky but usable plugin for anyone else who finds this thread -> https://github.com/MartinBeuriot/insomnia-plugin-gql-fragments

Alex-ray avatar Aug 18 '22 22:08 Alex-ray

4 years later :(

HugoTigre avatar Sep 06 '23 09:09 HugoTigre

Insomnia actually says on their homepage that you should be able to use fragments, but then no documentation anywhere ...

Screenshot 2023-11-27 at 07 47 24

andreweinhorn avatar Nov 27 '23 05:11 andreweinhorn

This issue is on my radar. We will look into it in January after the holidays.

subnetmarco avatar Dec 21 '23 18:12 subnetmarco

Any updates on this? (@subnetmarco) This feature would be really useful!

Bas950 avatar Apr 04 '24 08:04 Bas950