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 #import #385

Closed
dobesv opened this issue Apr 13, 2021 · 2 comments · Fixed by #441
Closed

Support #import #385

dobesv opened this issue Apr 13, 2021 · 2 comments · Fixed by #441
Labels
kind/enhancement New feature or request

Comments

@dobesv
Copy link
Contributor

dobesv commented Apr 13, 2021

Our graphql systems support an #import directive in graphql files to allow sharing fragments between operations in different files.

e.g.

#import './TeacherProfileUser.fragment.graphql'
#import './ProfileSettingsContainer/ProfileSettings/StandardsPreferences/StandardsPreferences.fragment.graphql'
#import "../../core/viewer.fragment.graphql"

mutation TeacherProfileUpdateUser($userId: ID!, $input: UserInput!) {
  updateUser(id: $userId, input: $input) {
    user {
      ...TeacherProfileUserFragment
      ...StandardsPreferencesUserFragment
      ...ViewerFragment
    }
  }
}

Currently this file gives an error:

/home/ubuntu/app/src/ui/client/teacher/profile/TeacherProfile.mutation.graphql
   8:12  error  Unknown fragment "TeacherProfileUserFragment"        @graphql-eslint/known-fragment-names
   9:12  error  Unknown fragment "StandardsPreferencesUserFragment"  @graphql-eslint/known-fragment-names
  10:12  error  Unknown fragment "ViewerFragment"                    @graphql-eslint/known-fragment-names

It would be nice if this support could be ported over to this linter somehow.

@oliverlukesch
Copy link

Stumbled upon the same problem, support for imports would be greatly appreciated

@dotansimha dotansimha added the kind/enhancement New feature or request label Apr 20, 2021
@ardatan
Copy link
Member

ardatan commented May 18, 2021

@oliverlukesch For now you can provide your operations under parserOptions like below;

{
  "parserOptions": {
     "operations": "/path/to/operations/*.graphql"
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

4 participants