near-operation-file: 同一文件中的另一个 gql 标签中定义的片段会失去 *FragmentDoc,因为 visitor-plugin-common 2.13.8

作者: RobHannay创建于 2026年9月2日更新于 2026年9月2日

schema.graphql

graphql
type Query { thing: Thing }
type Thing { id: ID! name: String }

src/Thing.ts

typescript
import { gql } from "@apollo/client";
gql`fragment ThingFields on Thing { id name }`;
gql`query GetThing { thing { ...ThingFields } } ${ThingFields}`;

codegen.ts

typescript
export default {
  schema: "schema.graphql",
  documents: ["src/**/*.ts", "!src/**/*.generated.ts"],
  generates: {
    "src/generated/graphql.ts": { plugins: ["TypeScript"] },
…

内容来源: dotansimha/graphql-code-generator