Skip to content

Commit bb7e473

Browse files
heiskrCopilot
andauthored
Add GraphQL transformer for Article API (#58719)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0b2516e commit bb7e473

23 files changed

+1264
-1
lines changed

src/article-api/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ The `/api/article` endpoints return information about a page by `pathname`.
2323

2424
### Autogenerated Content Transformers
2525

26-
For autogenerated pages (REST, landing pages, audit logs, webhooks, GraphQL, etc), the Article API uses specialized transformers to convert the rendered content into markdown format. These transformers are located in `src/article-api/transformers/` and use an extensible architecture:
26+
For autogenerated pages (REST, GraphQL, webhooks, landing pages, audit logs, etc), the Article API uses specialized transformers to convert the rendered content into markdown format. These transformers are located in `src/article-api/transformers/` and use an extensible architecture:
27+
28+
#### Current Transformers
29+
30+
- **REST Transformer** (`rest-transformer.ts`) - Converts REST API operations into markdown, including endpoints, parameters, status codes, and code examples
31+
- **GraphQL Transformer** (`graphql-transformer.ts`) - Converts GraphQL schema documentation into markdown, including queries, mutations, objects, interfaces, enums, unions, input objects, scalars, changelog, and breaking changes
2732

2833
To add a new transformer for other autogenerated content types:
2934
1. Create a new transformer file implementing the `PageTransformer` interface
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# {{ pageTitle }}
2+
3+
{{ pageIntro }}
4+
5+
{{ manualContent }}
6+
7+
{% for change in breakingChangesByDate %}
8+
9+
## {{ change.heading }}
10+
11+
{% for item in change.items %}
12+
13+
- {% if item.criticality == 'breaking' %}**Breaking**{% else %}**Dangerous**{% endif %} A change will be made to `{{ item.location }}`.
14+
15+
**Description:** {{ item.description }}
16+
17+
**Reason:** {{ item.reason }}
18+
19+
{% endfor %}
20+
21+
{% endfor %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# {{ pageTitle }}
2+
3+
{{ pageIntro }}
4+
5+
{{ manualContent }}
6+
7+
{% for item in changelogItems %}
8+
9+
## Schema changes for {{ item.date }}
10+
11+
{% for schemaChange in item.schemaChanges %}
12+
13+
### {{ schemaChange.title }}
14+
15+
{% for change in schemaChange.changes %}- {{ change }}
16+
{% endfor %}
17+
18+
{% endfor %}
19+
20+
{% for previewChange in item.previewChanges %}
21+
22+
### {{ previewChange.title }}
23+
24+
{% for change in previewChange.changes %}- {{ change }}
25+
{% endfor %}
26+
27+
{% endfor %}
28+
29+
{% for upcomingChange in item.upcomingChanges %}
30+
31+
### {{ upcomingChange.title }}
32+
33+
{% for change in upcomingChange.changes %}- {{ change }}
34+
{% endfor %}
35+
36+
{% endfor %}
37+
38+
{% endfor %}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# {{ pageTitle }}
2+
3+
{{ pageIntro }}
4+
5+
{{ manualContent }}
6+
7+
## Reference pages
8+
9+
{{ childrenLinks }}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# {{ pageTitle }}
2+
3+
{{ pageIntro }}
4+
5+
{{ manualContent }}
6+
7+
{% for item in items %}
8+
9+
## {{ item.name }}
10+
11+
{{ item.description }}
12+
13+
{% if item.isDeprecated %}
14+
15+
> [!WARNING]
16+
> **Deprecation notice:** {{ item.deprecationReason }}
17+
{% endif %}
18+
19+
{% if pageType == 'queries' %}
20+
**Type:** [{{ item.type }}]({{ item.href }})
21+
22+
{% if item.args.size > 0 %}
23+
24+
### Arguments for `{{ item.name }}`
25+
26+
| Name | Type | Description |
27+
| --- | --- | --- |
28+
{% for arg in item.args %}| `{{ arg.name }}` | [`{{ arg.type }}`]({{ arg.href }}) | {{ arg.description }} |
29+
{% endfor %}
30+
{% endif %}
31+
32+
{% elsif pageType == 'mutations' %}
33+
{% if item.inputFields.size > 0 %}
34+
35+
### Input fields for `{{ item.name }}`
36+
37+
| Name | Type | Description |
38+
| --- | --- | --- |
39+
{% for field in item.inputFields %}| `{{ field.name }}` | [`{{ field.type }}`]({{ field.href }}) | {{ field.description }}{% if field.defaultValue %} Default: `{{ field.defaultValue }}`.{% endif %} |
40+
{% endfor %}
41+
{% endif %}
42+
43+
{% if item.returnFields.size > 0 %}
44+
45+
### Return fields for `{{ item.name }}`
46+
47+
| Name | Type | Description |
48+
| --- | --- | --- |
49+
{% for field in item.returnFields %}| `{{ field.name }}` | [`{{ field.type }}`]({{ field.href }}) | {{ field.description }}{% if field.defaultValue %} Default: `{{ field.defaultValue }}`.{% endif %}{% if field.isDeprecated %} **Deprecated:** {{ field.deprecationReason }}{% endif %} |
50+
{% endfor %}
51+
{% endif %}
52+
53+
{% elsif pageType == 'objects' %}
54+
{% if item.implements.size > 0 %}
55+
56+
### Implements
57+
58+
{% for impl in item.implements %}- [`{{ impl.name }}`]({{ impl.href }})
59+
{% endfor %}
60+
{% endif %}
61+
62+
{% if item.fields.size > 0 %}
63+
64+
### Fields for `{{ item.name }}`
65+
66+
| Name | Type | Description |
67+
| --- | --- | --- |
68+
{% for field in item.fields %}| `{{ field.name }}` | [`{{ field.type }}`]({{ field.href }}) | {{ field.description }}{% if field.defaultValue %} Default: `{{ field.defaultValue }}`.{% endif %}{% if field.isDeprecated %} **Deprecated:** {{ field.deprecationReason }}{% endif %}{% if field.arguments.size > 0 %}<br><br>**Arguments:**<br>{% for arg in field.arguments %}- `{{ arg.name }}` ([`{{ arg.type.name }}`]({{ arg.type.href }})): {{ arg.description }}{% if arg.defaultValue %} Default: `{{ arg.defaultValue }}`.{% endif %}<br>{% endfor %}{% endif %} |
69+
{% endfor %}
70+
{% endif %}
71+
72+
{% elsif pageType == 'interfaces' %}
73+
{% if item.fields.size > 0 %}
74+
75+
### Fields for `{{ item.name }}`
76+
77+
| Name | Type | Description |
78+
| --- | --- | --- |
79+
{% for field in item.fields %}| `{{ field.name }}` | [`{{ field.type }}`]({{ field.href }}) | {{ field.description }}{% if field.defaultValue %} Default: `{{ field.defaultValue }}`.{% endif %}{% if field.isDeprecated %} **Deprecated:** {{ field.deprecationReason }}{% endif %}{% if field.arguments.size > 0 %}<br><br>**Arguments:**<br>{% for arg in field.arguments %}- `{{ arg.name }}` ([`{{ arg.type.name }}`]({{ arg.type.href }})): {{ arg.description }}{% if arg.defaultValue %} Default: `{{ arg.defaultValue }}`.{% endif %}<br>{% endfor %}{% endif %} |
80+
{% endfor %}
81+
{% endif %}
82+
83+
{% elsif pageType == 'enums' %}
84+
{% if item.values.size > 0 %}
85+
86+
### Values for `{{ item.name }}`
87+
88+
{% for value in item.values %}**`{{ value.name }}`**
89+
90+
{{ value.description }}
91+
92+
{% endfor %}
93+
{% endif %}
94+
95+
{% elsif pageType == 'unions' %}
96+
{% if item.possibleTypes.size > 0 %}
97+
98+
### Possible types for `{{ item.name }}`
99+
100+
{% for type in item.possibleTypes %}- [`{{ type.name }}`]({{ type.href }})
101+
{% endfor %}
102+
{% endif %}
103+
104+
{% elsif pageType == 'inputObjects' %}
105+
{% if item.inputFields.size > 0 %}
106+
107+
### Input fields for `{{ item.name }}`
108+
109+
| Name | Type | Description |
110+
| --- | --- | --- |
111+
{% for field in item.inputFields %}| `{{ field.name }}` | [`{{ field.type }}`]({{ field.href }}) | {{ field.description }}{% if field.defaultValue %} Default: `{{ field.defaultValue }}`.{% endif %}{% if field.isDeprecated %} **Deprecated:** {{ field.deprecationReason }}{% endif %} |
112+
{% endfor %}
113+
{% endif %}
114+
115+
{% elsif pageType == 'scalars' %}
116+
{%- comment -%}Scalars typically just have name and description{%- endcomment -%}
117+
118+
{% endif %}
119+
120+
{% endfor %}

0 commit comments

Comments
 (0)