ardatan / graphql-import

Import & export definitions in GraphQL SDL
868 stars 56 forks source link

TypeError: Cannot read property 'location' of undefined #522

Closed lynnic26 closed 4 years ago

lynnic26 commented 4 years ago
const typeDefs = await importSchema('./schema.graphql');

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

surfjedi commented 4 years ago

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 "./"

surfjedi commented 4 years ago

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

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

lynnic26 commented 4 years ago

@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