Js-graphql-intellij-plugin: [Question] Unknown fragment, load fragment from node_modules?

Created on 24 Oct 2019  路  5Comments  路  Source: jimkyndemeyer/js-graphql-intellij-plugin

Version and Environment Details

__Operation system__: macOS

__IDE name and version__: Webstorm 2019.2

__Plugin version__: 2.2.0

image

I have a gatsby project where I get this warning "Unknown fragment GatsbyImageSharpFluid". I do not have a definition for this fragment in my own source code, but the definition exists in package gatsby-transformer-sharp. It is a fragment that defines all the fields needed for other plugins to work.

Question:
Can I configure something to make the plugin understand these fragments located in node_modules/gatsby-transformer-sharp/fragments.js? The fragments are exported from the package, I tried importing them but still not working.

Here is a snippet from node_modules/gatsby-transformer-sharp/fragments.js:

const GatsbyImageSharpFluid = _gatsby.graphql`
  fragment GatsbyImageSharpFluid on ImageSharpFluid {
    base64
    aspectRatio
    src
    srcSet
    sizes
  }
`;
/**
 * Traced SVG fluid images
 * @type {Fragment}
 */

exports.GatsbyImageSharpFluid = GatsbyImageSharpFluid;

I guess I could just copy paste the fragment definitions to my own source code, but is there a way to discover fragments in npm packages? :)

Most helpful comment

Hi Thomas.

Thanks for using the plugin.

Please see https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/236 for how to make this work.

Best regards,
Jim.

All 5 comments

Hi Thomas.

Thanks for using the plugin.

Please see https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/236 for how to make this work.

Best regards,
Jim.

Thank you 馃槉 馃檹

Hey @jimkyndemeyer is this work-around included in the docs for js-graphql? Perhaps I skimmed too quick, but if it's not, what do you think about adding a note? Particularly for those working with Gatsby.

Hi @jimkyndemeyer, would it be possible to allow searching outside of the "Project scope" through a configuration parameter or something like that?

I use Rider for my frontend development and don't have much control over the "Project scope" for my javascript files, since I don't have them attached to a dotnet solution.
The walkaround of marking certain packages in the node_modules directory as "not excluded" therefore seems to be unavailable to me, since node_modules probably for good reason is excluded by default.

Edit:
I'm only referring to the "includes" and "excludes" part of the configuration here, so that files outside of the "Project scope" must be declared there.

Just FYI, I've been having the exact same issue and I wasn't able to get any of the solutions from #236 to work. I think it's related to how the gatsby-image fragments don't work in the GraphiQL IDE either (see my post on #236).

This is only a problem because it shows the error Unknown fragment spread "GatsbyImageSharpFluid". Besides that, everything works as expected. I just wish there was some way to disable the error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanquinn3 picture ryanquinn3  路  5Comments

MegaJSDeveloper picture MegaJSDeveloper  路  3Comments

vjpr picture vjpr  路  4Comments

rlancer picture rlancer  路  3Comments

idkjs picture idkjs  路  3Comments