有没有一种方法可以对vscode中的`(重音符)内的语法高亮显示GraphQl TypeDef进行语法? [英] There is a way to syntax highlight GraphQl TypeDef inside ` ` (grave accent) in vscode?

查看:35
本文介绍了有没有一种方法可以对vscode中的`(重音符)内的语法高亮显示GraphQl TypeDef进行语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想语法突出显示typeDef中的代码.有可能吗?

I Want to syntax highlight the code inside typeDef. It is possible?

对此有扩展名吗?还是我必须以其他方式编写typeDef的代码?

There is a extension for this? Or I have to code the typeDef other way?

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!
 }
`;

推荐答案

假设您使用的是

Assuming you're using the right extension, you need to use the gql tag from graphql-tag.

const gql = require('graphql-tag')

const typeDefs = gql`
  type User { ... }
`

标记解析提供的字符串并返回一个 DocumentNode 对象,该对象应该传递给 makeExecutableSchema ApolloServer 构造函数.在客户端,ApolloClient使用的查询也应该是 DocumentNode 对象,并且应该以相同的方式包装.

The tag parses the provided string and returns a DocumentNode object, which is what should be passed to makeExecutableSchema or the ApolloServer constructor. On the client side, the queries used by ApolloClient are also expected to be DocumentNode objects and should be wrapped the same way.

该扩展程序能够检测到标记的用法并相应地应用语法突出显示.

The extension is able to detect usage of the tag and apply syntax highlighting accordingly.

这篇关于有没有一种方法可以对vscode中的`(重音符)内的语法高亮显示GraphQl TypeDef进行语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆