Skip to content

Commit 69afec4

Browse files
authored
fix SchemaPointer type, allow both URLs with headers and local type definitions (#1406)
1 parent 90e58ab commit 69afec4

File tree

5 files changed

+60
-43
lines changed

5 files changed

+60
-43
lines changed

.changeset/wicked-pots-clap.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'graphql-config': patch
3+
---
4+
5+
fix `SchemaPointer` type, allow both URLs with headers and local type definitions

config-schema.json

+42-25
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"title": "include"
5353
},
5454
"schema": {
55-
"$ref": "#/definitions/SchemaPointer",
55+
"$ref": "#/definitions/WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>",
5656
"title": "schema"
5757
}
5858
},
@@ -112,52 +112,69 @@
112112
"title": "IGraphQLProjects",
113113
"type": "object"
114114
},
115-
"SchemaPointer": {
115+
"WithList<string>": {
116116
"anyOf": [
117117
{
118118
"items": {
119119
"type": "string"
120120
},
121121
"type": "array"
122122
},
123-
{
124-
"items": {
125-
"additionalProperties": {
126-
"properties": {
127-
"headers": {
128-
"additionalProperties": {
129-
"type": "string"
130-
},
131-
"title": "headers",
132-
"type": "object"
133-
}
134-
},
135-
"required": ["headers"],
136-
"type": "object"
137-
},
138-
"type": "object"
139-
},
140-
"type": "array"
141-
},
142123
{
143124
"type": "string"
144125
}
145126
],
146-
"title": "SchemaPointer"
127+
"title": "WithList<string>"
147128
},
148-
"WithList<string>": {
129+
"WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>": {
149130
"anyOf": [
131+
{
132+
"additionalProperties": {
133+
"properties": {
134+
"headers": {
135+
"additionalProperties": {
136+
"type": "string"
137+
},
138+
"title": "headers",
139+
"type": "object"
140+
}
141+
},
142+
"required": ["headers"],
143+
"type": "object"
144+
},
145+
"type": "object"
146+
},
150147
{
151148
"items": {
152-
"type": "string"
149+
"anyOf": [
150+
{
151+
"additionalProperties": {
152+
"properties": {
153+
"headers": {
154+
"additionalProperties": {
155+
"type": "string"
156+
},
157+
"title": "headers",
158+
"type": "object"
159+
}
160+
},
161+
"required": ["headers"],
162+
"type": "object"
163+
},
164+
"type": "object"
165+
},
166+
{
167+
"type": "string"
168+
}
169+
]
153170
},
154171
"type": "array"
155172
},
156173
{
157174
"type": "string"
158175
}
159176
],
160-
"title": "WithList<string>"
177+
"title": "WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>"
161178
}
162179
},
163180
"description": "Structure of GraphQL Config"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"ts-node": "10.9.1",
9292
"tsx": "3.12.7",
9393
"typescript": "5.1.6",
94-
"typescript-json-schema": "0.59.0",
94+
"typescript-json-schema": "0.61.0",
9595
"vitest": "0.33.0"
9696
},
9797
"repository": {

pnpm-lock.yaml

+8-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ export interface IGraphQLProjectLegacy {
3333

3434
export declare type WithList<T> = T | T[];
3535
export declare type ElementOf<TList> = TList extends Array<infer TElement> ? TElement : never;
36-
export declare type SchemaPointer =
37-
| WithList<string>
36+
export declare type SchemaPointer = WithList<
37+
| string
3838
| {
3939
[url: string]: {
4040
headers: {
4141
[name: string]: string;
4242
};
4343
};
44-
}[];
44+
}
45+
>;
4546
export declare type SchemaPointerSingle = ElementOf<SchemaPointer>;
4647
export declare type DocumentGlobPathPointer = string;
4748
export declare type DocumentPointer = WithList<DocumentGlobPathPointer>;

0 commit comments

Comments
 (0)