apollographql / apollographql/apollo-server
ENOENT: no such file or directory, open './schema.graphql'
- Dominant language
- TypeScript
- Stars
- 14k
- Forks
- 2k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 2
Description
### Issue Description
Going over docs I stuck on https://www.apollographql.com/docs/apollo-server/workflow/generate-types
The documentation says:
"move your server's schema into a .graphql file" and then use it like so:
```
// ...other imports
import { readFileSync } from 'fs';
// Note: this uses a path relative to the project's
// root directory, which is the current working directory
// if the server is executed using `npm run`.
const typeDefs = readFileSync('./schema.graphql', { encoding: 'utf-8' });
```
Error:
```
node:fs:592
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, open './schema.graphql'
at Object.openSync (node:fs:592:3)
at readFileSync (node:fs:460:35)
at file:///Users//index.js:6:18
at ModuleJob.run (node:internal/modules/esm/module_job:192:25) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: './schema.graphql'
}
```
### Link to Reproduction
https://github.com/egor-sorokin/graphql-try
### Reproduction Steps
- install dependecies
- run `npm run start`
Contributor guide
Research direction
Start with the generate-types documentation linked in the issue and reproduce the failure using the linked graphql-try project and `npm run start`. Check how the example resolves `schema.graphql` relative to the working directory; done means the documented setup no longer produces ENOENT or clearly explains the required file location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100