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

Suport #include files #94

Closed
mbellezi opened this issue Sep 2, 2017 · 8 comments
Closed

Suport #include files #94

mbellezi opened this issue Sep 2, 2017 · 8 comments
Labels

Comments

@mbellezi
Copy link

mbellezi commented Sep 2, 2017

Greetings,

I suggest support the #include file notation as in:

http://dev.apollodata.com/react/webpack.html#Fragments

Examples:
#import "./UserInfoFragment.graphql"
and
#import "graphql-tag/loader!../../graphql-defs/contacts.graphql"

This way we can modularize a lot the queries.

Regards

@andrewgrewell
Copy link

Any thoughts on this @jimkyndemeyer? I would also find this helpful, any ideas on how this might be done and I could possibly do a PR

@jimkyndemeyer
Copy link
Collaborator

Hi Andrew.

I think the first question you should think about is how you want the plugin to behave differently than what it does today. I'm thinking of feature areas such as go to definition, error highlighting, completion, query execution and so forth.

Once you have that figured out, please describe it here, and I'll be better able to offer guidance. Depending on the scope, I would say this feature requires some experience with the IntelliJ Platform SDK, including working with PSI trees and the virtual file system.

@andrewgrewell
Copy link

Thanks Jim, I'll look into it a bit more and give back with my findings.

@iamdanthedev
Copy link

iamdanthedev commented Nov 11, 2017

Hi
Unfortunately I know nothing about the IntelliJ platform, but have to say the the feature would be very handy!

Or at least of we could supress the error message somehow..

Thanks for effort!

@BerndWessels
Copy link

@jimkyndemeyer I haven't studied your code yet, but hope it will not be to hard to process the #import statement and concatenate the imported files content before running any further processing on it.

Main improvements:

  1. Get rid of errors that are caused by the fact that the plugin ignores imported files.
  2. Get the full functionality and awesomeness of the plugin working with files that use the #import statement to import other .graphql files to break up source code into cleaner smaller chunks.

@haizz
Copy link

haizz commented Sep 5, 2018

+100

@andrewgrewell
Copy link

For what it's worth I got around this by writing a file watcher that watches my .graphql files and is looking for #import, it resolves the file and then writes it to one .graphql file that is used by the plugin.

jimkyndemeyer added a commit that referenced this issue Apr 14, 2019
…243, #43, #94)

- Highlight current executable operation and included fragments
- Automatically include referenced fragments, including across files based on resolving PSI references
@jimkyndemeyer
Copy link
Collaborator

The RFC to add imports to GraphQL was closed without arriving at a standardized solution.

The 2.0 release of this plugin shipped with a capability to resolve fragments across files, but bounded by schema scopes defined using graphql-config. The scoping allows for control over which fragments are visible from specific operations. Completion and error highlighting for fragment spreads follows this scoped resolution logic.

For the upcoming 2.1 release contextual queries will automatically include these "resolvable" fragments when executing operations against GraphQL endpoints.

This approach allows developers to use whatever import mechanism they deem as most fitting while adding a better DX while working with this plugin. The developers must take care to test their components actually import the required fragments, but testing is an established best practice.

With the 2.0 release the plugin achieved compliance with the June 2018 GraphQL spec. Should imports become a part of an upcoming spec version I'll revisit as needed.

Best regards,
Jim.

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

No branches or pull requests

6 participants