Js-graphql-intellij-plugin: 2017.1 EAP Not detecting Relay.QL`...` usage

Created on 10 Feb 2017  路  7Comments  路  Source: jimkyndemeyer/js-graphql-intellij-plugin

Basically as the title says the plugin isn't detecting Relay.QL usage and so I'm not getting any help.

I imagine it may be related to this https://github.com/facebook/relay/issues/1537 but I figure this plugin is probably the best place to address this for now and I noticed that importing RelayPublic helped the IDE understand that it is a thing, the graphql query still isn't highlighted?

image

Note that individual .graphql files are fine and can query the endpoint, and the code itself works fine in use.

Here's an example code block:

import React from 'react'
import Relay from 'react-relay'
import {Link} from 'react-router'
import gravatar from 'gravatar-url';

class ListItem extends React.Component {

    static propTypes = {
        member: React.PropTypes.object,
        router: React.PropTypes.object,
    }

    render() {
        return (
                <a href={`/view/${this.props.member.id}`}>
                    <Img src={gravatar(this.props.member.email, {size: 500})} alt="User Avatar"/>
                    <p><strong>{this.props.member.name}</strong></p>
                    <p>{this.props.member.email}</p>
                </a>
        )
    }
}

export default Relay.createContainer(ListItem, {
        fragments: {
            member: () => Relay.QL`
                fragment on Member {
                    id
                    name
                    email
                }
            `,
        },
    }
)

Most helpful comment

Fixed in v1.5.1, pending JetBrains approval.

All 7 comments

Hi Matthew.

I'd like you to create a new project from scratch, and use Relay.QL in a new js/jsx file. This should help pinpoint whether it's specific to your current project.

Thanks,
Jim.

Hi @jimkyndemeyer

Here's the new repo for reference https://github.com/hailwood/bare-bones-graphql-error-repo


I created a new project from scratch,

ran yarn add react-relay to add relay
created a new test.jsx file with

import Relay from 'react-relay';

Relay.QL`
`

Issue still persisted.


I created tester.graphql to prompt the plugin to create the graphql.config.json file.
I filled it out with valid details and ran a query to ensure it was working in .graphql files (it is).


I then renamed the file to test.js and updated the JS version phpstorm was using to support imports.
No change.


What I did note is that it seems to work fine if I manually inject the language into the template literal.

Just for kicks I also tried it with gql after yarn add graphql-tag; and noticed the same behaviour.

import gql from 'graphql-tag';

gql`
    viewer {

    }
`;

What's probably relevant and I apologise for not mentioning it in the initial issue is I am running the latest EAP on ubuntu.

I'm unable to reproduce this with stable versions of IntelliJ Idea and WebStorm (2016.3). This is what I see with your repo:

image

Since no one else has reported this as an issue, I'd like you to try with a stable version.

Hey @jimkyndemeyer,

So you're spot on, the stable version picks it up and works perfect...
So I guess the question now is, is there a bug in the EAP, or is there an upcoming change that the plugin will need to be aware of?

I don't mind logging a bug report against the EAP, just not sure what I would say that wouldn't result in them just saying "report it to the plugin author" so would like to do some more debugging with you before I lodge the report if required.

Something that is interesting is comparing the AST from the stable version compared to the EAP.
The EAP is parsing the file quite a bit differently, so I have a feeling that this isn't a bug, but rather is it detecting new elements which is breaking our checks?

image

This is a breaking change in their PSI, which renders the EAP and the current plugin version incompatible.

See https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/blob/master/src/main/com/intellij/lang/jsgraphql/ide/injection/JSGraphQLLanguageInjectionUtil.java#L80-L84

I'd prefer not to have multiple versions and branches of the plugin, but that might not be possible with this change.

In any case, I'll work on a solution.

Thanks for catching this.

/Jim

Fixed in v1.5.1, pending JetBrains approval.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

victororlyk picture victororlyk  路  3Comments

MaxmaxmaximusAWS picture MaxmaxmaximusAWS  路  4Comments

Globegitter picture Globegitter  路  5Comments

rlancer picture rlancer  路  3Comments

ryanquinn3 picture ryanquinn3  路  5Comments