Circular dependencies with multiple files
Closed this issue · 2 comments
ryannealmes commented
Importing files with circular dependencies does not work when importing multiple .graphql
files.
I wrote some simple functionality that is broken up into multiple files. The code below - user and team both relate to each other.
const { importSchema } = require('graphql-import');
const path = require('path');
const team = importSchema(path.join(__dirname, 'team.graphql'));
const user = importSchema(path.join(__dirname, 'user.graphql'));
const query = importSchema(path.join(__dirname, 'query.graphql'));
const schema = importSchema(path.join(__dirname, 'schema.graphql'));
module.exports = [
user,
team,
query,
schema
];
I then tested the same code in a single file.
const { importSchema } = require('graphql-import');
const path = require('path');
const schema = importSchema(path.join(__dirname, 'schema.graphql'));
module.exports = [
schema
];
Single schema file
schema {
query: Query
}
type Query {
users: [User]
user: User
teams: [Team]
team: Team
}
type Team {
name: String
description: String
users: [User]
}
type User {
firstName: String
lastName: String
teams: [Team]
}
This works. Any chance this can be extended to work with multiple files?
SpaceK33z commented
Should be fixed with 0.7.0
, feel free to re-open if the issue still occurs.