graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
557 stars 71 forks source link

Add support for graphql.config.ts #334

Closed IanVS closed 2 years ago

IanVS commented 2 years ago

Actual Behavior

Attempting to use a typescript config file results in:

graphql-language-service-usage-logs: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'

It looks like graphql.config.ts is supported by graphql-config: https://graphql-config.com/introduction#graphqlconfigts-or-graphqlrcts

Expected Behavior

I should be able to export a config from a typescript file.

Steps to Reproduce the Problem Or Description

Define a config using a typescript file.

Specifications

Logs Of TS Server || GraphQL Language Service

10/26/2021, 2:50:12 PM [4] (pid: 8601) graphql-language-service-usage-logs: {"type":"usage","messageType":"initialize"}
10/26/2021, 2:50:14 PM [1] (pid: 8601) graphql-language-service-usage-logs: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
10/26/2021, 2:50:14 PM [1] (pid: 8601) graphql-language-service-usage-logs: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
10/26/2021, 2:50:14 PM [1] (pid: 8601) graphql-language-service-usage-logs: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
acao commented 2 years ago

Woah! last I updated this there wasn't support, but I introduced a PR for TS and TOML support so maybe they merged it, cool!

acao commented 2 years ago

this was added in the latest release, but there are other issues which may cause editor features to not load.

sandervspl commented 2 years ago

I am still getting this error when trying to use a .ts config with version 4.1.0

import type { IGraphQLConfig } from 'graphql-config';

const config: IGraphQLConfig = {
  schemaPath: './schema.graphql',
  documents: ['./src/**/*.graphql'],
  extensions: {
    endpoints: {
      default: {
        url: `https://graphql.contentful.com/content/v1/spaces/${process.env.NEXT_PUBLIC_CF_SPACE_ID}`,
        headers: { Authorization: `Bearer ${process.env.NEXT_PUBLIC_CF_DELIVERY_ACCESS_TOKEN}` },
      },
    },
  },
};

export default config;
luisgregson commented 2 years ago

this was added in the latest release, but there are other issues which may cause editor features to not load.

Can you advise what the other issues are? I'm still seeing "ConfigNotFoundError2: GraphQL Config file is not available in the provided config directory", but i'm not sure what to check next