我想语法突出显示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!
}
`;
答案 0 :(得分:1)
假设您正在使用right extension,则需要使用gql
中的graphql-tag
标签。
const gql = require('graphql-tag')
const typeDefs = gql`
type User { ... }
`
标记解析提供的字符串并返回DocumentNode
对象,该对象应传递给makeExecutableSchema
或ApolloServer
构造函数。在客户端,ApolloClient使用的查询也应该是DocumentNode
对象,并且应该以相同的方式包装。
该扩展程序能够检测到标记的用法并相应地应用语法突出显示。
答案 1 :(得分:1)
使用 String.raw 欺骗 VSCode 进入语法高亮 GraphQL。它也适用于其他语言。
<div id='form__option3' class="form__option form__option3">
<input id="Input NameShipper" type="text" class="InputReciever field" />
</div>