graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

File imports in a master schemata fail to resolve transitive dependencies nested more than one level

Open jacob-carpenter opened this issue 3 years ago • 1 comments

Describe the bug When 2 GraphQL files are imported in a chain from a starting master schema containing only imports, the dependencies of the imported definitions will not resolve past a single level.

Example:

File 1

# import Query.* from './level2.graphql'

File 2

type User {
    accountId: Int
}

type PaginatedWrapper{
    user: User
}

type Query {
    pagination: PaginatedWrapper
}

Produces

type PaginatedWrapper {
  user: User
}

type Query {
  pagination: PaginatedWrapper
}

To Reproduce Steps to reproduce the behavior: Run graphql-codegen for a schema definition matching the aforementioned convention. This [branch]{https://github.com/jacob-carpenter/graphql-tools/tree/master-schema-test-case) contains a test case reproducing this issue.

Expected behavior Following the aforementioned example, the final result should be:

type PaginatedWrapper {
  user: User
}

type Query {
  pagination: PaginatedWrapper
}

type User {
  accountId: Int
}

Environment:

  • OS: Mac OS Big Sur 11.6
  • @graphql-tools/load: 7.3.1
  • NodeJS: 14

Additional context I believe i have a working solution, and will issue a pull request shortly.

jacob-carpenter avatar Sep 27 '21 16:09 jacob-carpenter

can we get a new release now that this merged please? :-D thanks!!

hikirsch avatar Sep 28 '21 23:09 hikirsch