diff --git a/package-lock.json b/package-lock.json index b7e99ae..7278ab6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "garph", - "version": "0.6.5", + "version": "0.6.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "garph", - "version": "0.6.5", + "version": "0.6.6", "license": "MIT", "dependencies": { "graphql-compose": "^9.0.10", diff --git a/package.json b/package.json index 44572a4..c87aab1 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "git", "url": "https://github.com/stepci/garph" }, - "version": "0.6.5", + "version": "0.6.6", "license": "MIT", "main": "dist/index.js", "scripts": { @@ -15,7 +15,7 @@ "build": "tsc -p tsconfig.json", "postbuild": "typedoc --readme none --entryDocument index.md --plugin typedoc-plugin-markdown --tsconfig tsconfig.json --hideInPageTOC true --out www/api src/index.ts", "ts:check": "tsc -p tsconfig.test.json", - "test": "ts-node examples/relay.ts" + "test": "ts-node examples/promo.ts" }, "devDependencies": { "@graphql-yoga/plugin-defer-stream": "^2.0.4", diff --git a/src/index.ts b/src/index.ts index ecb77ef..2a19466 100644 --- a/src/index.ts +++ b/src/index.ts @@ -596,7 +596,7 @@ class GArgs extends Type { } export class GarphSchema { - types: AnyType[] = [] + types: Map = new Map() nodeType = this.interface('Node', { id: this.id() @@ -618,12 +618,8 @@ export class GarphSchema { registerType(type: AnyType) { const name = type.typeDef.name - if (name) { - if (this.types.find(t => t.typeDef.name === name)) { - throw new Error(`Detected multiple types with name: ${name}`) - } - } - this.types.push(type) + if (this.types.has(name)) throw new Error(`Type with name "${name}" already exists`) + this.types.set(name, type) } constructor ({ types }: { types: AnyType[] } = { types: [] }) { diff --git a/www/api/classes/GarphSchema.md b/www/api/classes/GarphSchema.md index 52987b6..0b63f99 100644 --- a/www/api/classes/GarphSchema.md +++ b/www/api/classes/GarphSchema.md @@ -17,7 +17,7 @@ #### Defined in -[index.ts:629](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L629) +[index.ts:625](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L625) ## Properties @@ -27,7 +27,7 @@ #### Defined in -[index.ts:601](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L601) +[index.ts:601](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L601) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -[index.ts:612](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L612) +[index.ts:612](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L612) ___ @@ -56,17 +56,17 @@ ___ #### Defined in -[index.ts:605](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L605) +[index.ts:605](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L605) ___ ### types -• **types**: [`AnyType`](../index.md#anytype)[] = `[]` +• **types**: `Map`<`string`, [`AnyType`](../index.md#anytype)\> #### Defined in -[index.ts:599](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L599) +[index.ts:599](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L599) ## Methods @@ -80,7 +80,7 @@ ___ #### Defined in -[index.ts:714](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L714) +[index.ts:710](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L710) ___ @@ -108,7 +108,7 @@ ___ #### Defined in -[index.ts:645](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L645) +[index.ts:641](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L641) ___ @@ -136,7 +136,7 @@ ___ #### Defined in -[index.ts:655](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L655) +[index.ts:651](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L651) ___ @@ -164,7 +164,7 @@ ___ #### Defined in -[index.ts:674](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L674) +[index.ts:670](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L670) ___ @@ -178,7 +178,7 @@ ___ #### Defined in -[index.ts:710](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L710) +[index.ts:706](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L706) ___ @@ -192,7 +192,7 @@ ___ #### Defined in -[index.ts:702](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L702) +[index.ts:698](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L698) ___ @@ -220,7 +220,7 @@ ___ #### Defined in -[index.ts:668](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L668) +[index.ts:664](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L664) ___ @@ -234,7 +234,7 @@ ___ #### Defined in -[index.ts:706](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L706) +[index.ts:702](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L702) ___ @@ -262,7 +262,7 @@ ___ #### Defined in -[index.ts:692](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L692) +[index.ts:688](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L688) ___ @@ -290,7 +290,7 @@ ___ #### Defined in -[index.ts:639](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L639) +[index.ts:635](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L635) ___ @@ -316,7 +316,7 @@ ___ #### Defined in -[index.ts:720](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L720) +[index.ts:716](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L716) ___ @@ -336,7 +336,7 @@ ___ #### Defined in -[index.ts:619](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L619) +[index.ts:619](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L619) ___ @@ -364,7 +364,7 @@ ___ #### Defined in -[index.ts:686](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L686) +[index.ts:682](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L682) ___ @@ -378,7 +378,7 @@ ___ #### Defined in -[index.ts:698](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L698) +[index.ts:694](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L694) ___ @@ -406,7 +406,7 @@ ___ #### Defined in -[index.ts:633](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L633) +[index.ts:629](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L629) ___ @@ -434,4 +434,4 @@ ___ #### Defined in -[index.ts:680](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L680) +[index.ts:676](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L676) diff --git a/www/api/classes/Type.md b/www/api/classes/Type.md index 4ec5454..d20a4ea 100644 --- a/www/api/classes/Type.md +++ b/www/api/classes/Type.md @@ -30,7 +30,7 @@ #### Defined in -[index.ts:13](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L13) +[index.ts:13](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L13) ___ @@ -40,7 +40,7 @@ ___ #### Defined in -[index.ts:11](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L11) +[index.ts:11](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L11) ___ @@ -50,7 +50,7 @@ ___ #### Defined in -[index.ts:10](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L10) +[index.ts:10](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L10) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[index.ts:9](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L9) +[index.ts:9](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L9) ___ @@ -70,7 +70,7 @@ ___ #### Defined in -[index.ts:12](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L12) +[index.ts:12](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L12) ___ @@ -80,7 +80,7 @@ ___ #### Defined in -[index.ts:14](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L14) +[index.ts:14](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L14) ___ @@ -90,7 +90,7 @@ ___ #### Defined in -[index.ts:15](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L15) +[index.ts:15](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L15) ## Methods @@ -110,7 +110,7 @@ ___ #### Defined in -[index.ts:22](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L22) +[index.ts:22](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L22) ___ @@ -130,4 +130,4 @@ ___ #### Defined in -[index.ts:17](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L17) +[index.ts:17](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L17) diff --git a/www/api/index.md b/www/api/index.md index 1e0625e..cd57550 100644 --- a/www/api/index.md +++ b/www/api/index.md @@ -15,7 +15,7 @@ garph #### Defined in -[index.ts:58](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L58) +[index.ts:58](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L58) ___ @@ -25,7 +25,7 @@ ___ #### Defined in -[index.ts:46](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L46) +[index.ts:46](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L46) ___ @@ -35,7 +35,7 @@ ___ #### Defined in -[index.ts:54](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L54) +[index.ts:54](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L54) ___ @@ -45,7 +45,7 @@ ___ #### Defined in -[index.ts:49](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L49) +[index.ts:49](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L49) ___ @@ -55,7 +55,7 @@ ___ #### Defined in -[index.ts:45](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L45) +[index.ts:45](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L45) ___ @@ -65,7 +65,7 @@ ___ #### Defined in -[index.ts:56](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L56) +[index.ts:56](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L56) ___ @@ -75,7 +75,7 @@ ___ #### Defined in -[index.ts:48](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L48) +[index.ts:48](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L48) ___ @@ -85,7 +85,7 @@ ___ #### Defined in -[index.ts:57](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L57) +[index.ts:57](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L57) ___ @@ -95,7 +95,7 @@ ___ #### Defined in -[index.ts:51](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L51) +[index.ts:51](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L51) ___ @@ -105,7 +105,7 @@ ___ #### Defined in -[index.ts:47](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L47) +[index.ts:47](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L47) ___ @@ -115,7 +115,7 @@ ___ #### Defined in -[index.ts:60](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L60) +[index.ts:60](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L60) ___ @@ -129,7 +129,7 @@ ___ #### Defined in -[index.ts:71](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L71) +[index.ts:71](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L71) ___ @@ -139,7 +139,7 @@ ___ #### Defined in -[index.ts:61](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L61) +[index.ts:61](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L61) ___ @@ -149,7 +149,7 @@ ___ #### Defined in -[index.ts:59](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L59) +[index.ts:59](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L59) ___ @@ -159,7 +159,7 @@ ___ #### Defined in -[index.ts:52](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L52) +[index.ts:52](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L52) ___ @@ -169,7 +169,7 @@ ___ #### Defined in -[index.ts:50](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L50) +[index.ts:50](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L50) ___ @@ -179,7 +179,7 @@ ___ #### Defined in -[index.ts:55](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L55) +[index.ts:55](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L55) ___ @@ -189,7 +189,7 @@ ___ #### Defined in -[index.ts:44](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L44) +[index.ts:44](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L44) ___ @@ -199,7 +199,7 @@ ___ #### Defined in -[index.ts:43](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L43) +[index.ts:43](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L43) ___ @@ -213,7 +213,7 @@ ___ #### Defined in -[index.ts:67](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L67) +[index.ts:67](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L67) ___ @@ -223,7 +223,7 @@ ___ #### Defined in -[index.ts:53](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L53) +[index.ts:53](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L53) ___ @@ -237,7 +237,7 @@ ___ #### Defined in -[index.ts:63](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L63) +[index.ts:63](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L63) ___ @@ -254,7 +254,7 @@ ___ #### Defined in -[index.ts:93](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L93) +[index.ts:93](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L93) ___ @@ -270,7 +270,7 @@ ___ #### Defined in -[index.ts:125](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L125) +[index.ts:125](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L125) ___ @@ -286,7 +286,7 @@ ___ #### Defined in -[index.ts:126](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L126) +[index.ts:126](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L126) ___ @@ -302,7 +302,7 @@ ___ #### Defined in -[index.ts:120](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L120) +[index.ts:120](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L120) ___ @@ -318,7 +318,7 @@ ___ #### Defined in -[index.ts:121](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L121) +[index.ts:121](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L121) ___ @@ -335,7 +335,7 @@ ___ #### Defined in -[index.ts:94](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L94) +[index.ts:94](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L94) ___ @@ -352,7 +352,7 @@ ___ #### Defined in -[index.ts:134](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L134) +[index.ts:134](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L134) ___ @@ -369,7 +369,7 @@ ___ #### Defined in -[index.ts:156](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L156) +[index.ts:156](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L156) ___ @@ -386,7 +386,7 @@ ___ #### Defined in -[index.ts:108](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L108) +[index.ts:108](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L108) ___ @@ -402,7 +402,7 @@ ___ #### Defined in -[index.ts:132](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L132) +[index.ts:132](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L132) ___ @@ -435,7 +435,7 @@ ___ #### Defined in -[index.ts:28](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L28) +[index.ts:28](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L28) ## Variables @@ -445,7 +445,7 @@ ___ #### Defined in -[index.ts:733](https://github.com/stepci/garph/blob/45f35d4/src/index.ts#L733) +[index.ts:729](https://github.com/stepci/garph/blob/11bfe12/src/index.ts#L729) ## Functions @@ -468,7 +468,7 @@ ___ #### Defined in -[schema.ts:17](https://github.com/stepci/garph/blob/45f35d4/src/schema.ts#L17) +[schema.ts:17](https://github.com/stepci/garph/blob/11bfe12/src/schema.ts#L17) ___ @@ -489,4 +489,4 @@ ___ #### Defined in -[schema.ts:11](https://github.com/stepci/garph/blob/45f35d4/src/schema.ts#L11) +[schema.ts:11](https://github.com/stepci/garph/blob/11bfe12/src/schema.ts#L11)