apollographql / apollographql/apollo-server

ENOENT: no such file or directory, open './schema.graphql'

Open
#7,767 1 comment 1 reaction 0 assignees View on GitHub
:memo: documentation
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.