# argano/graphql-codegen-documents architecture

> Architecture diagram of the GitHub repository argano/graphql-codegen-documents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/argano/graphql-codegen-documents
- Repository: https://github.com/argano/graphql-codegen-documents

## Overview

graphql-codegen-documents is a GraphQL Code Generator plugin that creates query, mutation, and subscription documents from a schema while excluding operations already present in supplied documents. The principal workflow is: Code Generator supplies schema, documents, and config; the plugin entry point parses and visits the schema and documents; the generator visitor builds output text, which is written as a generated GraphQL document for later Code Generator plugins. The README also documents a separate, preceding plugin run. This map is based on the README and sampled source; external Code Generator internals are not expanded.

Main entry points: [`src/index.ts`](https://github.com/argano/graphql-codegen-documents/blob/master/src/index.ts) (Plugin function), [`src/visitor.ts`](https://github.com/argano/graphql-codegen-documents/blob/master/src/visitor.ts) (Document generator), [`src/operations-visitor.ts`](https://github.com/argano/graphql-codegen-documents/blob/master/src/operations-visitor.ts) (Operation visitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin entry"]
  node_index["Plugin function<br/>[index.ts]"]
end

subgraph group_visitors["AST visitors"]
  node_ops["Operation visitor"]
  node_generator["Document generator<br/>[visitor.ts]"]
end

subgraph group_workflow["Codegen workflow"]
  node_generated["Generated documents"]
  node_later(("Later Codegen plugins"))
end

node_codegen(("GraphQL Codegen"))
node_schema["GraphQL schema"]
node_documents["Existing documents"]

node_codegen -->|"invokes plugin"| node_index
node_codegen -->|"supplies schema"| node_schema
node_codegen -->|"supplies documents"| node_documents
node_index -->|"prints schema"| node_schema
node_index -->|"concatenates ASTs"| node_documents
node_index -->|"visits document AST"| node_ops
node_index -->|"visits schema AST"| node_generator
node_index -->|"gets operation names"| node_ops
node_index -->|"requests generation"| node_generator
node_generator -->|"returns document text"| node_generated
node_later -.->|"reads documents"| node_generated

click node_index "https://github.com/argano/graphql-codegen-documents/blob/master/src/index.ts"
click node_ops "https://github.com/argano/graphql-codegen-documents/blob/master/src/operations-visitor.ts"
click node_generator "https://github.com/argano/graphql-codegen-documents/blob/master/src/visitor.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index toneBlue
class node_ops,node_generator toneAmber
class node_generated,node_later toneMint
class node_codegen,node_schema,node_documents toneIndigo
```

## Components

### Plugin entry

- [Plugin function](https://github.com/argano/graphql-codegen-documents/blob/master/src/index.ts): `src/index.ts`

### AST visitors

- [Operation visitor](https://github.com/argano/graphql-codegen-documents/blob/master/src/operations-visitor.ts): `src/operations-visitor.ts`
- [Document generator](https://github.com/argano/graphql-codegen-documents/blob/master/src/visitor.ts): `src/visitor.ts`

### Codegen workflow

- **Generated documents**
- **Later Codegen plugins**

### Other components

- **GraphQL Codegen**
- **GraphQL schema**
- **Existing documents**

## Connections

- GraphQL Codegen → Plugin function: invokes plugin
- GraphQL Codegen → GraphQL schema: supplies schema
- GraphQL Codegen → Existing documents: supplies documents
- Plugin function → GraphQL schema: prints schema
- Plugin function → Existing documents: concatenates ASTs
- Plugin function → Operation visitor: visits document AST
- Plugin function → Document generator: visits schema AST
- Plugin function → Operation visitor: gets operation names
- Plugin function → Document generator: requests generation
- Document generator → Generated documents: returns document text
- Later Codegen plugins → Generated documents: reads documents
