Quramy / ts-graphql-plugin

TypeScript Language Service Plugin for GraphQL developers
MIT License
720 stars 26 forks source link

TS IntelliSense doesn't show any completion for queries in VS Code #103

Open talentlessguy opened 4 years ago

talentlessguy commented 4 years ago

name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' ---Describe the bug Generated types aren't used by VS Code, so there are no any auto-completion options showing

To Reproduce

My case

  1. Run API, then generate types using pnpx ts-graphql-plugin typegen
  2. Extend Next.js config:
const TsGraphQLPlugin = require('ts-graphql-plugin/webpack')

const tsgqlPlugin = new TsGraphQLPlugin()

module.exports = {
  target: 'serverless',
  env:
    { API: 'http://localhost:8080', GRAPHQL: 'http://localhost:8080/graphql' },
  webpack: config => {
    config.module.rules.push({
      test: /\.tsx?$/,
      exclude: /node_modules/,
      loader: 'ts-loader',
      options: {
        getCustomTransformers: () => ({
          before: [tsgqlPlugin.getTransformer()]
        })
      }
    })
    return config
  }
}
  1. Put plugin inside of tsconfig:
{
  "compilerOptions": {
  // ...
    "plugins": [
      {
        "name": "ts-graphql-plugin",
        "schema": {
          "http": {
            "method": "POST",
            "url": "http://localhost:8080/graphql"
          }
        },
        "tag": "gql"
      }
    ]
  },
// ...
}

Manual installation

Clone two repos, build api, launch it, then build frontend

git clone https://github.com/komfy/frontend.git
cd frontend
pnpm i # or npm i
pnpm run dev # or npm run dev
pnpx ts-graphql-plugin typegen # or npx ts-graphql-plugin typegen

Expected behavior I expected my exported types to autocomplete my queries

Debug log

image

talentlessguy commented 4 years ago

Update: after trying to rebuild the application with extended config, it hangs