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

Support importing fragments #3

Open
kumarharsh opened this issue Apr 18, 2017 · 6 comments
Open

Support importing fragments #3

kumarharsh opened this issue Apr 18, 2017 · 6 comments

Comments

@kumarharsh
Copy link
Contributor

kumarharsh commented Apr 18, 2017

Transferred from kumarharsh/graphql-for-vscode#22

@majodev said:

Enhancement, see documentation in gql-tag.

@kumarharsh said:

@majodev - from what I read, this is a webpack feature rather than an editor feature. Can you clarify exactly what you mean?

@majodev said:

Sure, this allows to import fragments from other files, however the plugin does not understand the import syntax, which leads to NoUnusedFragments and KnownFragmentNames errors.

See the attached screenshot.
bildschirmfoto 2017-03-31 um 12 02 20

@kumarharsh said:

OK, I understand, thanks for the screenshot too. I'll look into how to do this.

@kumarharsh said:

I think the gql repo will be the best place to handle this.

@jvbianchi
Copy link

any news?

@Mayank1791989
Copy link
Owner

@jvbianchi you can disable validation rules to suppress errors

// .gqlconfig
{
  match: "path/to/files",
  validate: {
    extends: "gql-rules-query",
    rules: {
      KnownFragmentNames: "off",
      NoUnusedFragments: "off"
    }
  }
}

@jvbianchi
Copy link

@Mayank1791989 I done it. It solved the errors for me. Thanks

@mgadda
Copy link

mgadda commented Dec 12, 2017

I'm not sure that suppressing the errors is necessarily the best solution. One might want to know, for instance, about truly unknown or unused fragments, not just fragments from other files.

graphql-language-service provides a good model for how I think it could work. All of the fragments glob'd from query.files.match have their fragments stored in a map of name to parsed fragment. This information is made available as needed for autocompletion, validation, etc of queries that may reference fragments specified in the same file or other files. Essentially, everything that gets glob'd is globally namespaced. No #imports required.

@Mayank1791989
Copy link
Owner

I'm not sure that suppressing the errors is necessarily the best solution. One might want to know, for instance, about truly unknown or unused fragments, not just fragments from other files.

@mgadda suppressing errors is only a temp solution for above import based graphql files as I dont want to implement #imports which is not part of graphql spec and very specific to javascript language client.

All of the fragments glob'd from query files.

Yes It's already on the roadmap of next version to support relay-modern client and it will be something similar to that.

@ntziolis
Copy link

Any update on this?

Mayank1791989 added a commit that referenced this issue Apr 18, 2018
BREAKING_CHANGE: structure of .gqlconfig file changed.

closes #3, closes #23, closes #28, closes #45, closes #52, closes #62, closes #99, closes #100, closes #115
Mayank1791989 added a commit that referenced this issue Apr 30, 2018
BREAKING_CHANGE: structure of .gqlconfig file changed.

closes #3, closes #23, closes #28, closes #45, closes #52, closes #62, closes #99, closes #100, closes #115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants