visual-studio-code - 有一种方法可以在 vscode 中的 ` `(重音符)内语

我想语法高亮 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/

相关文章:

javascript - 使用 JavaScript 检测按键持续时间

python - 如何在 asyncio create_task 中更新全局变量

python - 从包含文本格式数据的其他列创建 Pandas 数据框的列

javascript - 使用javascript在数组中首先缺少正整数?

java - JUnit 测试方法无法返回值

session - Nuxt Apollo 具有用于基于 session 的身份验证的动态 head

firebase - 在 Firebase 云存储中加载预览时出错

swift - 将核心数据同步到 CloudKit 公共(public)数据库

haskell - 函数重载以最小化重复模式

javascript - YouTube 视频 API 片段标题包含 Next.js 中的特殊字符