vscode-apollo-relay icon indicating copy to clipboard operation
vscode-apollo-relay copied to clipboard

Relay 13 support

Open petrbela opened this issue 4 years ago • 3 comments

Seems Relay 13 no longer uses relay-config. What is the configuration we should pass to apollo.client.js? If I follow the expanded example in readme, it throws Unable to load relay-compiler, so 'includes' may need manual configuration. when calling generateConfig, followed by Cannot read property 'schemaExtensions' of undefined.

FWIW, I can set up the Apollo VSCode plugin and get field autocompletion without this plugin and setting apollo.config.js to the following (but not sure what features from this plugin I'm missing and will need later?):

module.exports = {
  client: {
    tagName: 'graphql',
    service: {
      name: '...',
      localSchemaFile: './schema.graphql',
    },
  },
}

petrbela avatar Mar 04 '22 14:03 petrbela

Relay specific stuff doesn't seem to work at least. with that setup. Unknown directive "@refetchable".GraphQL: Validation

FINDarkside avatar Apr 25 '22 13:04 FINDarkside

you can actually add support for Relay-specific directives using external definitions, using e.g. this project.

I actually included a local definition file with what I need instead, by adding it to the schema list in my .graphqlrc.yml conf file:

schema: 
  - "./data/schema.graphql"
  - "./data/relay-directives.graphql"
documents: "./src/**/*.{ts,tsx}"
relay-directives.graphql
directive @connection(
  key: String!
  filters: [String]
  handler: String
  dynamicKey_UNSTABLE: String
) on FIELD

directive @refetchable(queryName: String!) on FRAGMENT_DEFINITION

directive @arguments on FRAGMENT_SPREAD

input First {
  type: String!
  defaultValue: Int!
}

input After {
  type: String!
}

directive @argumentDefinitions(
  first: First
  after: After
) on FRAGMENT_DEFINITION

directive @raw_response_type on QUERY | MUTATION | SUBSCRIPTION

directive @relay(plural: Boolean!) on FRAGMENT_DEFINITION

micheleb avatar Apr 25 '22 14:04 micheleb

FYI, there's an official Relay VSCode extension in the works to be available as soon as the next Relay version is released.

petrbela avatar May 13 '22 04:05 petrbela