Skip to content

@graphql-tools/git-loader can't find definitions if they are in the upper directory #5101

@inokawa

Description

@inokawa

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

@graphql-tools/git-loader can't find graphql definitions if they are in the upper directory.
This might be because git ls-tree can't search upper directory by default.

To Reproduce
Steps to reproduce the behavior:

  1. Create a monorepo like project structure.
├── .git
├── schemas
│   └── sample.graphql
└── packages
    └── graphql-loader
        └── index.js
        └── package.json
  1. Move to packages/graphql-loader dir.
  2. Run packages/graphql-loader/index.js. The code is like below.
import { loadSchema } from '@graphql-tools/load';
import { GitLoader } from '@graphql-tools/git-loader';

(async () => {
  const schema = await loadSchema('git:origin/master:./schemas/**/*.graphql', {
    loaders: [new GitLoader()],
  });
  console.log(schema);
})();
  1. Step 3 will throw Error: Unable to find any GraphQL type definitions for the following pointers:.
  2. Even if we pass cwd option to loadSchema, it will fail.

Expected behavior

Can load graphql definitions.

Environment:

  • OS: macOS
  • @graphql-tools/git-loader: 7.2.20
  • @graphql-tools/load: 7.8.12
  • NodeJS: 19.7.0

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions