Reputation: 33
So when I start my server I get this list of errors
/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)
With all of this showing up. I don't really understand where my error is. Here is my schema file where I assume the error is
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]
Also here is my resolvers file if you think the errors could be stemming from it
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
If you see anything please let me know because I can't figure this one out. I am also using Sequelize for my DB connection with sqlite in case you are wondering what the syntax may be for my model queries.
Upvotes: 2
Views: 4241
Reputation: 4816
I think the error is in this line
type Query {
author(firstName: String, lastName: String): Author
allPosts(): [Post!]!
}
since allPost
has no parameters, it the parentesis aren't needed. it should be
type Query {
author(firstName: String, lastName: String): Author
allPosts: [Post!]!
}
running into cryptic errors like this,
throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token))
is most likely caused by invalid syntax in the schema file
Upvotes: 6