我想语法高亮 typeDef 中的代码。有可能吗?
这个有扩展吗?或者我必须以其他方式对 typeDef 进行编码?
export const typeDef = `
type User {
_id: ID!
email: String!
password: String
createdEvents: [Event!]
}
type AuthData {
userId: ID!
token: String!
tokenExpiration: Int!
}
input UserInput {
email: String!
password: String!
}
`;
最佳答案
使用String.raw将 VSCode 欺骗到语法高亮 GraphQL。它也适用于其他语言。
export const gql = String.raw
export const typeDef = gql`
type User {
_id: ID!
email: String!
password: String
createdEvents: [Event!]
}
type AuthData {
userId: ID!
token: String!
tokenExpiration: Int!
}
input UserInput {
email: String!
password: String!
}
`
关于visual-studio-code - 有一种方法可以在 vscode 中的 ` `(重音符)内语法高亮显示 GraphQl TypeDef 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60643685/