You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ...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/<location>/index.js:6:18
at ModuleJob.run (node:internal/modules/esm/module_job:192:25) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: './schema.graphql'
}
The problem is that tsc puts its output files in the dist directory, which is what ends up being the current directory at runtime. But it doesn't have a built-in way to copy other files to dist. There are plenty of work-arounds here (eg see the comments on that issue) — I'm not sure which one would be best for the docs.
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:
Error:
Link to Reproduction
https://github.com/egor-sorokin/graphql-try
Reproduction Steps
npm run start
The text was updated successfully, but these errors were encountered: