我正在使用 graphqljs 和 express-graphql
。每当我收到错误时,我都会得到一些模糊的信息,例如 "Expected type Int!, found\"1\"
with an unhelped location property:
"locations": [
{
"line": 3,
"column": 42
}
],
如何获取文件名及其行?
以下错误:
"{
"errors": [
{
"json": "{\"message\":\"Expected type Int!, found \\\"1\\\".\",\"locations\":[{\"line\":3,\"column\":42}]}",
"message": "Expected type Int!, found \"1\".",
"locations": [
{
"line": 3,
"column": 42
}
],
"stack": [
"GraphQLError: Expected type Int!, found \"1\".",
" at isValidScalar (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/validation/rules/ValuesOfCorrectType.js:164:27)",
" at Object.StringValue (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/validation/rules/ValuesOfCorrectType.js:128:14)",
" at Object.enter (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/language/visitor.js:333:29)",
" at Object.enter (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/language/visitor.js:384:25)",
" at visit (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/language/visitor.js:251:26)",
" at validate (/Applications/MAMP/htdocs/whylookforit-server/node_modules/graphql/validation/validate.js:63:22)",
" at /Applications/MAMP/htdocs/whylookforit-server/node_modules/express-graphql/dist/index.js:154:52",
" at processTicksAndRejections (internal/process/next_tick.js:81:5)"
]
}
]
}"
最佳答案
所有的 graphql 代码都会被捆绑到一个大模式中,只有在完成之后,coge 才会运行。如果模式运行时出现错误,则代码不再引用最初定义的文件。
关于javascript - graphqljs - 如何获取文件名和错误行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54900814/