首页 > 解决方案 > 如何设置graphql-config?

问题描述

我正在尝试graphql-config在 VSCode 中使用扩展,但我无法让它工作。我的语法改变了颜色schema.graphql,但是当我将鼠标悬停在类型定义上时,我什么也没得到,我不能使用“转到定义”等等。我.graphqlrc.yml的与schema.graphql. 这是我的文件夹结构:

gql-config
|    .graphqlrc.yml
|    package-lock.json
|    package.json
|    schema.graphql
|____node_modules
    | ...

.graphqlrc.yml

schema: 'schema.graphql'
documents: 'schema.graphql'

schema.graphql

type User {
  id: Int!
  name: String!
  posts: [Post!]!
}

type Post {
  id: Int!
  content: String!
  postedBy: User!
}

package.json

  "name": "gql-config",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "MIT",
  "dependencies": {
    "graphql": "^15.7.2",
    "graphql-config": "^4.1.0"
  }
}

我也试过

.graphqlrc.yml

schema: './schema.graphql'
documents: './schema.graphql'

.graphqlrc.yml

schema: '../schema.graphql'
documents: '../schema.graphql'

我在网上找到的示例要么不显示项目文件夹结构(官方文档站点),要么当我将它们从 Github 克隆到 VSCode 时它们不起作用(比如这个 repo)。我在全球安装了来自 GraphQL Foundation 的 GraphQL 扩展 v0.3.18。

标签: graphqlgraphql-jsgraphql-config

解决方案


推荐阅读