Skip to content

Commit

Permalink
fix SchemaPointer type, allow both URLs with headers and local type…
Browse files Browse the repository at this point in the history
… definitions (#1406)
  • Loading branch information
dimaMachina committed Oct 8, 2023
1 parent 90e58ab commit 69afec4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-pots-clap.md
@@ -0,0 +1,5 @@
---
'graphql-config': patch
---

fix `SchemaPointer` type, allow both URLs with headers and local type definitions
67 changes: 42 additions & 25 deletions config-schema.json
Expand Up @@ -52,7 +52,7 @@
"title": "include"
},
"schema": {
"$ref": "#/definitions/SchemaPointer",
"$ref": "#/definitions/WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>",
"title": "schema"
}
},
Expand Down Expand Up @@ -112,52 +112,69 @@
"title": "IGraphQLProjects",
"type": "object"
},
"SchemaPointer": {
"WithList<string>": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"items": {
"additionalProperties": {
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"title": "headers",
"type": "object"
}
},
"required": ["headers"],
"type": "object"
},
"type": "object"
},
"type": "array"
},
{
"type": "string"
}
],
"title": "SchemaPointer"
"title": "WithList<string>"
},
"WithList<string>": {
"WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>": {
"anyOf": [
{
"additionalProperties": {
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"title": "headers",
"type": "object"
}
},
"required": ["headers"],
"type": "object"
},
"type": "object"
},
{
"items": {
"type": "string"
"anyOf": [
{
"additionalProperties": {
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"title": "headers",
"type": "object"
}
},
"required": ["headers"],
"type": "object"
},
"type": "object"
},
{
"type": "string"
}
]
},
"type": "array"
},
{
"type": "string"
}
],
"title": "WithList<string>"
"title": "WithList<string|{[url:string]:{headers:{[name:string]:string;};};}>"
}
},
"description": "Structure of GraphQL Config"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -91,7 +91,7 @@
"ts-node": "10.9.1",
"tsx": "3.12.7",
"typescript": "5.1.6",
"typescript-json-schema": "0.59.0",
"typescript-json-schema": "0.61.0",
"vitest": "0.33.0"
},
"repository": {
Expand Down
22 changes: 8 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/types.ts
Expand Up @@ -33,15 +33,16 @@ export interface IGraphQLProjectLegacy {

export declare type WithList<T> = T | T[];
export declare type ElementOf<TList> = TList extends Array<infer TElement> ? TElement : never;
export declare type SchemaPointer =
| WithList<string>
export declare type SchemaPointer = WithList<
| string
| {
[url: string]: {
headers: {
[name: string]: string;
};
};
}[];
}
>;
export declare type SchemaPointerSingle = ElementOf<SchemaPointer>;
export declare type DocumentGlobPathPointer = string;
export declare type DocumentPointer = WithList<DocumentGlobPathPointer>;
Expand Down

0 comments on commit 69afec4

Please sign in to comment.