dotansimha / dotansimha/graphql-code-generator

[Initialization Wizard] cannot run codegen in the default output directory

Open
#9,157 0 comments 1 reaction 1 assignee Claimed by @saihaj View on GitHub
kind/bug stage/4-pull-request
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli

### Describe the bug

First of all, Thanks again for all your great work.

If codegen.ts is generated with the default output directory in the initial wizard, codegen cannot be executed as is.
See the reproduce section for more information.

### Your Example Website or App

https://github.com/MH4GF/reproduce-codegen-init-bug

### Steps to Reproduce the Bug or Issue

1. Run initialization wizard, with default answers

```
yarn graphql-code-generator init
yarn run v1.22.15
$ /Users/mh4gf/tmp/test-codegen/node_modules/.bin/graphql-code-generator init

Welcome to GraphQL Code Generator!
Answer few questions and we will setup everything for you.

? What type of application are you building? Application built with React
? Where is your schema?: (path or url) https://swapi-graphql.netlify.app/.netlify/functions/index
? Where are your operations and fragments?: src/**/*.tsx
? Where to write the output: src/gql
? Do you want to generate an introspection file? No
? How to name the config file? codegen.ts
? What script in package.json should run the codegen? codegen
Fetching latest versions of selected plugins...

Config file generated at codegen.ts

$ npm install

To install the plugins.

$ npm run codegen

To run GraphQL Code Generator.

✨ Done in 15.47s.
```

2. Comment out documents because we are not adding any operations.
3. Running codegen will result in an error.

```
yarn codegen
yarn run v1.22.15
$ graphql-codegen --config codegen.ts
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to src/gql
✔ Load GraphQL schemas

Unable to find any GraphQL type definitions for the following pointers:
-
◼ Generate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

### Expected behavior

The default output directory is `src/gql/`, not `src/gql`.

### Screenshots or Videos

_No response_

### Platform

- OS: macOS
- NodeJS: 16.16.0
- `graphql` version: 16.6.0
- `@graphql-codegen/*` version(s): 3.2.1

### Codegen Config File

```ts
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: "https://swapi-graphql.netlify.app/.netlify/functions/index",
// documents: "src/**/*.tsx",
generates: {
"src/gql": {
preset: "client",
plugins: []
}
}
};

export default config;
```

### Additional context

related: https://github.com/dotansimha/graphql-code-generator/discussions/8684

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.