Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.17k stars 1.92k forks source link

[Feature Request] Shared Fragments #1784

Open hannahmshin opened 4 years ago

hannahmshin commented 4 years ago

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

welcome[bot] commented 4 years ago

👋 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.

elemanhillary-zz commented 4 years ago

Theres a pending open PR that solves this

djchen commented 4 years ago

@elemanhillary Has that PR been merged? Thanks

xanderbuck commented 4 years ago

@elemanhillary any update on this?

briandiephuis commented 4 years ago

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

kreutter commented 4 years ago

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.

JaroVoltix commented 3 years ago

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

MatthewCawley commented 3 years ago

Any chance of this in 2021? :D

Le-Polemil commented 3 years ago

Would be very helpful 🙏🏻

sa9sha9 commented 3 years ago

please save us from fragments-hell 😈

elemanhillary-zz commented 3 years ago

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

RussBrown00 commented 3 years ago

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

velidan commented 3 years ago

We really need this feature

thonydam commented 3 years ago

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

pfcodes commented 3 years ago

Anybody figure out a good workaround?

teroqim commented 2 years ago

Any updates on this?

Alex-ray commented 2 years ago

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

Alex-ray commented 2 years ago

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

HugoTigre commented 11 months ago

4 years later :(

andreweinhorn commented 9 months ago

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
subnetmarco commented 8 months ago

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

Bas950 commented 4 months ago

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