Mayank1791989 / gql

112 stars 19 forks source link

Add apollo support #28

Open Mayank1791989 opened 7 years ago

Mayank1791989 commented 7 years ago

From @gaoxiaoliangz on June 2, 2017 11:31

When writing graphql queries, I often have to import external gql files and use them as fragments, like so:

const withData = graphql(gql`
  query queryBooks($id: ID!) {
    book(id: $id) {
      ...BookInfo
    }
  }
  ${BOOK_INFO}
`, {
    options: (props) => {
      return {
        variables: {
          id: props.params.id
        }
      }
    }
  })

but the plugin give me '[graphql] Syntax Error: Unexpected $' error. I know it seems to be an error for the plugin, but in the real world, it works fine, so how to disable that line of linting so it would not produce errors like that?

Copied from original issue: kumarharsh/graphql-for-vscode#31

Mayank1791989 commented 7 years ago

From @kumarharsh on June 5, 2017 12:8

@gaoxiaoliangz thank you for the report. The plugin shouldn't be throwing this error, as the interpolation you're doing is perfectly valid. I'm myself writing components like so: image

Please make sure that you're using the latest gql library. If you get this error even after updating, then can you give me a small example project which can reproduce this error?

Mayank1791989 commented 7 years ago

Actually, the plugin will throw an error as gql parser only support interpolation inside operations and fragments (relay style) not outside as in apollo.

tizmagik commented 6 years ago

Would this also need an isApollo: true config similar to isRelay: true that's in the docs?

Mayank1791989 commented 6 years ago

@tizmagik Yes you are right. But in v3 I have replaced isRelay with general env option which takes package name. This package comes with few env ('relay', 'apollo' and 'relay-modern') and new env can be added by creating new packages.

ntziolis commented 6 years ago

Is this supposed to work in the current version or if not any update on when it will land?

Mayank1791989 commented 6 years ago

@ntziolis I have released a new version v2.6 with document interpolation support.

bmayen commented 6 years ago

Confirming this works on my end after the update