dotansimha / dotansimha/graphql-code-generator-community

[near-operation-file] Introspection queries fail to generate - `Unable to find field "__type" on type "Query"!`

Open
#1,288 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

### Which packages are impacted by your issue?

*No response*

### Describe the bug

When using `near-operation-file` preset, codegen crashes with t his error: `Unable to find field "__type" on type "Query"!`
This is an example document:

```gql
query Test {
__type(name: "Role") {
enumValues(includeDeprecated: true) {
name
isDeprecated
}
}
}
```

### Your Example Website or App

[https://codesandbox.io/p/devbox/elastic-danilo-wg2p2q?workspaceId=ws_3d3S1CmTc7BCJtbnRB7BQC]()

### Steps to Reproduce the Bug or Issue

1. go to : [https://codesandbox.io/p/devbox/elastic-danilo-wg2p2q?workspaceId=ws_3d3S1CmTc7BCJtbnRB7BQC]()
2. open the terminal.

### Expected behavior

Introspection queries are being generated properly when not using this preset. it should work using the preset as well..

### Screenshots or Videos

*No response*

### Platform

* OS: \[e.g. macOS, Windows, Linux\]
* NodeJS: \[e.g. 18.5.0\]
* `graphql` version: \[e.g. 16.3.0\]
* `@graphql-codegen/*` version(s): \[e.g. 2.6.2\]

### Codegen Config File

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

const config: CodegenConfig = {
schema: "schema.graphql",
documents: "document.graphql",
generates: {
"types.ts": { plugins: ["typescript"] },
"./": {
preset: "near-operation-file",
presetConfig: {
// This should be the file generated by the "typescript" plugin above,
// relative to the directory specified for this configuration
baseTypesPath: "./types.ts",
folder: "@generated",
},
// Exclude the generated files, so we don't get duplications
plugins: ["typescript-operations"],
},
},
};

export default config;
```

### Additional context

*No response*

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.