我正在尝试设置一个GraphQL语言服务器,以便在NVIM中使用,通过CoC (完成征服)。
我已经从GraphQL 这里安装了LSP,但是我很难让它识别我的GQL模式。我目前正在使用阿波罗,所以我的模式在一个Javascript文件中。
设置LSP的例程是这里。
我已经在我的项目的根目录中放置了一个.graphqlrc文件,它指向一个包含我的模式的Javascript文件。
schema: api/src/schema.jsLanguage似乎会短暂运行并链接该文件,但是会很快崩溃,然后给出以下错误:
[Info - 3:47:22 PM] Connection to server got closed. Server will restart.
8/11/2021, 3:47:22 PM [4] (pid: 43189) graphql-language-service-usage-logs: {"type":"usage","messageType":"initialize"}
8/11/2021, 3:47:22 PM [1] (pid: 43189) graphql-language-service-usage-logs: Error:
Unable to find any GraphQL type definitions for the following pointers:
- api/src/schema.js以下是我的CoC设置文件:
// coc-settings.json
{
"languageserver": {
"graphql": {
"command": "graphql-lsp",
"args": ["server", "-m", "stream"],
"filetypes": [
"typescript",
"typescriptreact",
"graphql",
"javascript",
"javascriptreact"
]
}
},
}schema.js文件:
const { gql } = require('apollo-server');
/**
* Type Definitions for our Schema using the SDL.
*/
const typeDefs = gql`
type User {
id: ID!
username: String!
}
type Pet {
id: String!
createdAt: Int!
name: String!
type: String!
img: String!
}
type Query {
pets: [Pet]!
}
type Mutation {
cool: String!
}
`;
module.exports = typeDefs;发布于 2022-05-10 18:07:45
我认为问题在于schema.js不是一个有效的模式文件--它是一个生成运行时模式的程序。用于schema的graphql-lsp配置选项应该指向一个schema.gql文件,或者指向一个包含JSON数据的文件,该文件来自于对活动GraphQL服务的内省查询。
https://stackoverflow.com/questions/68750196
复制相似问题