apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 469 forks source link

[vscode-apollo] Autocomplete known fragments #1054

Open danielkcz opened 5 years ago

danielkcz commented 5 years ago

Thank you for this amazing extension. I wasn't really hoping something like this would appear anytime soon and be so simple in its nature ❤️

We do work with fragments a lot and there is bunch of them that are very common and used in many places. Each fragment sits alone in a *.gql file. It would be amazing if autocomplete would offer available fragments relevant for containing type.

There is a related issue (#182) so I assume fragments are not considered much just yet.

That would surely require for the extension to parse all graphql files beforehand (and based on changes) to collect available fragments and to what types they are related, but it should be doable, right?

hcharley commented 4 years ago

I'm also interested in having this feature. Would enable me to use this plugin with colocation of relevant queries and mutations to components, but centralize the fragments elsewhere.

ntziolis commented 4 years ago

We would be very interested to find out if this is possible by now. If not we are willing to dig in and invest time and ressource to enable this.

We understand that its possible today to use gql tags to use shared fragments, but we have moved to extracting all out graphql in separate .graphql files. And we are missing the ability todo this dearly.

Possible approaches:

In either case the fragments should then be available to all other graphql queries / mutations / subscriptions.

mountainash commented 3 years ago

@FredyC maybe the extension has changed since you first raised the issue, but as long as the “shared” fragments are referenced/included (and it’s allowed in the include definition in the apollo.config.js), it seems to work as expected for me.

import { ImageFragment, TagFragment } from "./Fragments";