ENOENT: no such file or directory, open './posts-schema.graphql'
thearabbit opened this issue · 3 comments
thearabbit commented
I base on Meteor, Apollo
?
Structure
/api/pos/
posts.graphql
posts-schema.graphql
startup.js
Code
// posts.graphql
type Post {
id: ID!
text: String!
tags: [String]
}
---
// posts-schema.graphql
# import Post from "posts.graphql"
type Query {
posts: [Post]
}
---
// startup.js
import { importSchema } from 'graphql-import'
console.log(importSchema('./posts-schema.graphql'))
Get error
Error: ENOENT: no such file or directory, open './posts-schema.graphql'
W20190822-09:36:34.332(7)? (STDERR) at Object.fs.openSync (fs.js:646:18)
W20190822-09:36:34.333(7)? (STDERR) at Object.fs.readFileSync (fs.js:551:33)
W20190822-09:36:34.333(7)? (STDERR) at read (/Volumes/DATA/MeteorApp/meteor-apollo/node_modules/graphql-import/dist/index.js:23:19)
W20190822-09:36:34.333(7)? (STDERR) at importSchema (/Volumes/DATA/MeteorApp/meteor-apollo/node_modules/graphql-import/dist/index.js:70:15)
W20190822-09:36:34.333(7)? (STDERR) at posts-import.js (imports/todo/api/assignees/posts-import.js:5:13)
W20190822-09:36:34.333(7)? (STDERR) at fileEvaluate (packages/modules-runtime.js:336:7)
W20190822-09:36:34.333(7)? (STDERR) at Module.require (packages/modules-runtime.js:238:14)
W20190822-09:36:34.333(7)? (STDERR) at Module.moduleLink [as link] (/Users/theara/.meteor/packages/modules/.0.13.0.1v462dq.d5l5++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/reify/lib/runtime/index.js:38:38)
ratneshraval commented
While researching, it looks like this can be resolved by using absolute path for .graphql
file.
Example here: https://github.com/didaquis/react-graphql-apollo-example-server/blob/master/src/gql/schemas/index.js
thearabbit commented
Thanks
enBonnet commented
Hey thanks @ratneshraval and im solve this with __dirname
instead of absolute path, example:
const helloType = importSchema(
${__ dirname}/hello.schema.graphql)