因此,当我启动服务器时,我会收到错误列表
/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:966
throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token));
^
GraphQLError
at syntaxError (/Users/charlie/workspace/HackQLServer/node_modules/graphql/error/syntaxError.js:28:15)
at expect (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:966:32)
at parseName (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:88:15)
at parseInputValueDef (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:743:14)
at many (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:1015:16)
at parseArgumentDefs (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:735:10)
at parseFieldDefinition (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:714:14)
at any (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:1002:16)
at parseObjectTypeDefinition (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:683:16)
at parseTypeSystemDefinition (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:607:16)
at parseDefinition (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:148:16)
at parseDocument (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:106:22)
at Object.parse (/Users/charlie/workspace/HackQLServer/node_modules/graphql/language/parser.js:43:10)
at buildSchemaFromTypeDefinitions (/Users/charlie/workspace/HackQLServer/node_modules/graphql-tools/src/schemaGenerator.ts:145:37)
at _generateSchema (/Users/charlie/workspace/HackQLServer/node_modules/graphql-tools/src/schemaGenerator.ts:72:18)
at makeExecutableSchema (/Users/charlie/workspace/HackQLServer/node_modules/graphql-tools/src/schemaGenerator.ts:97:20)
所有这一切都出现了。我真的不明白我的错误在哪里。这是我的模式文件,我假设错误是
const typeDefinitions = `
type Author {
id: Int
firstName: String
lastName: String
posts: [Post]
}
type Post {
id: Int
title: String
text: String
author: Author
}
type Query {
author(firstName: String, lastName: String): Author
allPosts(): [Post!]!
}
schema {
query: Query
}`
export default [typeDefinitions]
如果你认为错误可能源于它,那么这里是我的解析器文件
import { Author, Post } from './connectors'
const resolvers = {
Query: {
author: (root, args) => {
return Author.find({ where: args })
},
allPosts: (root, args) => {
return Post.findAll()
},
allAuthors: (root, args) => {
return Author.findAll()
}
},
Author: {
posts: (author) => {
return author.getPosts()
}
},
Post: {
author: (post) => {
return post.getAuthor()
}
}
}
export default resolvers
如果你看到任何东西请告诉我,因为我无法想出这个。我也在使用Sequelize与sqlite进行数据库连接,以防你想知道我的模型查询的语法是什么。
答案 0 :(得分:3)
我认为错误就在这一行
DateTime utcNow = DateTime.UtcNow;
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTimeOffset easternNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, tz);
由于Instant now = SystemClock.Instance.Now;
DateTimeZone tz = DateTimeZoneProviders.Tzdb["America/New_York"];
DateTimeOffset easternNow = now.InZone(tz).ToDateTimeOffset();
没有参数,因此不需要进行肠胃外检查。它应该是
type Query {
author(firstName: String, lastName: String): Author
allPosts(): [Post!]!
}
遇到这样的神秘错误,
allPost
很可能是由架构文件中的无效语法引起的