如何在egg-graphql中使用自定义标量
Open
Inactive
- Dominant language
- TypeScript
- Stars
- 19k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
## What happens?
我在使用egg-graphql时,期望设计一个不论输入什么,都返回0的标量类型,但是它并不起作用
首先我在schema.graphql文件中声明了它
`scalar ReturnZero`
然后实现了它
`'use strict';
const { GraphQLScalarType, } = require('graphql');
module.exports = {
ZeroInt:new GraphQLScalarType({
name: "ZeroInt",
description: "自定义标量",
parseLiteral(ast) {
return 0;
}
})
};
`
但是在测试时,这个标量类型可以使用,但是并没有如预期的那般返回0.
## 最小可复现仓库
https://github.com/Beiluola/egg-example.git
## 相关环境信息
- **操作系统**:windows 10
- **Node 版本**:v12.16.1
- **Egg 版本**: "egg": "^2.26.0", "egg-graphql": "^2.7.0"
Contributor guide
Assessment
This issue has not been assessed yet.