[javascript/graphql-apollo-server]: Unable to start example
See original GitHub issueHi there,
When I attempt to run this pared example as per this set of directions, I run into the following error in the command line:
Missing required typegen import: Context
This also manifests in the GraphQL Playground when I attempt to run any query through the following:
Expand me for graphql response
{
"error": {
"errors": [
{
"message": "Cannot query field \"users\" on type \"Query\".",
"locations": [
{
"line": 2,
"column": 3
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"users\" on type \"Query\".",
" at Object.Field (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:242:26)",
" at Object.validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/validate.js:73:24)",
" at validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:213:34)",
" at Object.<anonymous> (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at Generator.next (<anonymous>)",
" at fulfilled (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
},
{
"message": "Cannot query field \"user\" on type \"Query\".",
"locations": [
{
"line": 9,
"column": 3
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"user\" on type \"Query\".",
" at Object.Field (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:242:26)",
" at Object.validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/validate.js:73:24)",
" at validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:213:34)",
" at Object.<anonymous> (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at Generator.next (<anonymous>)",
" at fulfilled (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
},
{
"message": "Cannot query field \"createUser\" on type \"Mutation\". Did you mean \"createDraft\"?",
"locations": [
{
"line": 17,
"column": 3
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"createUser\" on type \"Mutation\". Did you mean \"createDraft\"?",
" at Object.Field (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:242:26)",
" at Object.validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/validate.js:73:24)",
" at validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:213:34)",
" at Object.<anonymous> (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at Generator.next (<anonymous>)",
" at fulfilled (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
},
{
"message": "Cannot query field \"updateUser\" on type \"Mutation\".",
"locations": [
{
"line": 25,
"column": 3
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"updateUser\" on type \"Mutation\".",
" at Object.Field (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:242:26)",
" at Object.validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/validate.js:73:24)",
" at validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:213:34)",
" at Object.<anonymous> (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at Generator.next (<anonymous>)",
" at fulfilled (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
},
{
"message": "Cannot query field \"deleteUser\" on type \"Mutation\". Did you mean \"deleteOnePost\"?",
"locations": [
{
"line": 33,
"column": 3
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"deleteUser\" on type \"Mutation\". Did you mean \"deleteOnePost\"?",
" at Object.Field (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/language/visitor.js:242:26)",
" at Object.validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/graphql/validation/validate.js:73:24)",
" at validate (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:213:34)",
" at Object.<anonymous> (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at Generator.next (<anonymous>)",
" at fulfilled (/Users/brianbancroft/programming/side-hustle/impressipies/graphql-apollo-server-api/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
}
]
}
}
Other pertinent details:
This was attempted with the latest LTS versions of Node, 12.16.2 and 10.20.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10
Top Results From Across the Web
Error handling - Apollo GraphQL Docs
Making errors actionable on the client and server. ... In the examples below, we use top-level await calls to start our server asynchronously....
Read more >Can't create a new test Apollo Server - node.js - Stack Overflow
Turns out I need at least 1 @Query decorator in my resolvers, I just added a dummy resolver until I need an actual...
Read more >apollo-server-express - npm
Production-ready Node.js GraphQL server for Express. Latest version: 3.11.1, last published: 2 months ago. Start using apollo-server-express ...
Read more >Creating a GraphQL Server with Apollo
createProduct(product: ProductInput), this should create a product. Let's start a new file resolvers.js . At this point, we will keep things simple and...
Read more >Top 5 apollo-server Code Examples - Snyk
To help you get started, we've selected a few apollo-server examples, based on popular ... Create GraphQL server const server = new ApolloServer({...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This doesn’t seem to be the right approach. Prisma should theoretically support both .js and .ts and should be language agnostic. The right approach would be to fix the code to accept both .js and .ts files.
@Benjaminryejones Thank you for the reply.
When I run
npm run build
the code runs without an error.This is in line with your comment, because there is a file named “context.ts” in the /src folder.
This then generates a “context.js” file in the /dist folder.
When I then fun
npm run start
(which runsnode dist/server
), that is when the error appears.It does not feel right to rename this file to “context.ts” at this point.
I guess the problem is in the schema.ts file at this piece of code:
Is there a way to make
npm run start
(node dist/server
) to run without the error?