Skip to content

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

@ItaiYosephi

Description

@ItaiYosephi

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:

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

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

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