ardatan/graphql-import

TypeError: Cannot read property 'location' of undefined

Closed this issue · 3 comments

const typeDefs = await importSchema('./schema.graphql');

version: graphql-import@v1.0.0-beta.2

Yes I am having this same error if the schema.graphql is not a sibling of the file(main.ts) that has "const typeDefs = await importSchema('../schema.graphql');" in it...

But I can get it to work by removing "../" in the file path and copying the "schema.graphql" file to the same directory as main.ts..
as in this:
"const typeDefs = await importSchema('schema.graphql');

NOTE: @lynnic26 mine desired file path is slightly off from yours I have issues with "../" as yorus appears to be "./"

@lynnic26 actually just got this working use path/join:

import { join } from "path";
const typeDefs = await importSchema(join(__dirname, "../schema.graphql"));

@lynnic26 actually just got this working use path/join:

import { join } from "path";
const typeDefs = await importSchema(join(__dirname, "../schema.graphql"));

Yes, I have figured it out.
anyway, thx