@gql.tada/internal
Advanced tools
Comparing version 0.2.4 to 0.3.0-canary-0e6bf0c1d11563469036c776550836617d7cf4c6
# @gql.tada/internal | ||
## 0.3.0-canary-0e6bf0c1d11563469036c776550836617d7cf4c6 | ||
### Minor Changes | ||
- Add multi-schema config format and schema loading | ||
Submitted by [@kitten](https://github.com/kitten) (See [#257](https://github.com/0no-co/gql.tada/pull/257)) | ||
### Patch Changes | ||
- Update `loadRef` to reflect `tada*` options to result types | ||
Submitted by [@kitten](https://github.com/kitten) (See [#259](https://github.com/0no-co/gql.tada/pull/259)) | ||
## 0.2.4 | ||
@@ -4,0 +16,0 @@ |
@@ -5,15 +5,51 @@ import { IntrospectionQuery, GraphQLSchema } from 'graphql'; | ||
interface IntrospectionResult extends IntrospectionQuery { | ||
name: string | undefined; | ||
} | ||
interface SchemaLoaderResult { | ||
introspection: IntrospectionQuery; | ||
introspection: IntrospectionResult; | ||
schema: GraphQLSchema; | ||
tadaOutputLocation?: string; | ||
tadaTurboLocation?: string; | ||
tadaPersistedLocation?: string; | ||
} | ||
type OnSchemaUpdate = (result: SchemaLoaderResult) => void; | ||
interface SchemaLoader { | ||
readonly name: string | undefined; | ||
load(reload?: boolean): Promise<SchemaLoaderResult>; | ||
notifyOnUpdate(onUpdate: OnSchemaUpdate): () => void; | ||
/** @internal */ | ||
loadIntrospection(): Promise<IntrospectionQuery | null>; | ||
loadIntrospection(): Promise<IntrospectionResult | null>; | ||
/** @internal */ | ||
loadSchema(): Promise<GraphQLSchema | null>; | ||
} | ||
interface BaseLoadConfig { | ||
rootPath?: string; | ||
fetchInterval?: number; | ||
assumeValid?: boolean; | ||
} | ||
type SingleSchemaInput = { | ||
name?: string; | ||
schema: SchemaOrigin; | ||
tadaOutputLocation?: string; | ||
tadaTurboLocation?: string; | ||
tadaPersistedLocation?: string; | ||
}; | ||
type MultiSchemaInput = { | ||
schemas?: SingleSchemaInput[]; | ||
}; | ||
interface SchemaRef<Result = SchemaLoaderResult | null> { | ||
/** Starts automatically updating the ref */ | ||
autoupdate( | ||
config: BaseLoadConfig, | ||
onUpdate: (ref: SchemaRef<Result>, input: SingleSchemaInput) => void | ||
): () => void; | ||
/** Loads the initial result for the schema */ | ||
load(config: BaseLoadConfig): Promise<SchemaRef<SchemaLoaderResult>>; | ||
current: Result; | ||
multi: { | ||
[name: string]: Result; | ||
}; | ||
version: number; | ||
} | ||
type SchemaOrigin = | ||
@@ -27,2 +63,3 @@ | string | ||
interface LoadFromSDLConfig { | ||
name?: string; | ||
assumeValid?: boolean; | ||
@@ -34,2 +71,3 @@ file: string; | ||
interface LoadFromURLConfig { | ||
name?: string; | ||
url: URL | string; | ||
@@ -45,9 +83,10 @@ headers?: HeadersInit; | ||
} | null; | ||
interface LoadConfig { | ||
interface LoadConfig extends BaseLoadConfig { | ||
name?: string; | ||
origin: SchemaOrigin; | ||
rootPath?: string; | ||
fetchInterval?: number; | ||
assumeValid?: boolean; | ||
} | ||
declare function load(config: LoadConfig): SchemaLoader; | ||
declare function loadRef( | ||
input: SingleSchemaInput | MultiSchemaInput | (SingleSchemaInput & MultiSchemaInput) | ||
): SchemaRef; | ||
@@ -64,3 +103,7 @@ declare class TSError extends Error { | ||
interface GraphQLSPConfig { | ||
interface BaseConfig { | ||
template?: string; | ||
} | ||
interface SchemaConfig { | ||
name?: string; | ||
schema: SchemaOrigin; | ||
@@ -70,5 +113,18 @@ tadaOutputLocation?: string; | ||
tadaPersistedLocation?: string; | ||
template?: string; | ||
} | ||
interface MultiSchemaConfig extends SchemaConfig { | ||
name: string; | ||
} | ||
type GraphQLSPConfig = BaseConfig & | ||
( | ||
| SchemaConfig | ||
| { | ||
schemas: MultiSchemaConfig[]; | ||
} | ||
); | ||
declare const parseConfig: (input: unknown, rootPath?: string) => GraphQLSPConfig; | ||
declare const getSchemaConfigForName: ( | ||
config: GraphQLSPConfig, | ||
name: string | undefined | ||
) => SchemaConfig | null; | ||
@@ -105,5 +161,9 @@ declare const readTSConfigFile: (filePath: string) => Promise<TsConfigJson>; | ||
*/ | ||
declare const minifyIntrospectionQuery: (schema: IntrospectionQuery) => IntrospectionQuery; | ||
declare const minifyIntrospectionQuery: ( | ||
schema: IntrospectionQuery | IntrospectionResult | ||
) => IntrospectionResult; | ||
declare function preprocessIntrospection({ __schema: schema }: IntrospectionQuery): string; | ||
declare function preprocessIntrospection( | ||
introspection: IntrospectionResult | IntrospectionQuery | ||
): string; | ||
@@ -115,3 +175,3 @@ interface OutputIntrospectionFileOptions { | ||
declare function outputIntrospectionFile( | ||
introspection: IntrospectionQuery | string, | ||
introspection: IntrospectionQuery | IntrospectionResult, | ||
opts: OutputIntrospectionFileOptions | ||
@@ -121,12 +181,20 @@ ): string; | ||
export { | ||
type BaseConfig, | ||
type BaseLoadConfig, | ||
type GraphQLSPConfig, | ||
type IntrospectionResult, | ||
type LoadConfig, | ||
type LoadConfigResult, | ||
type MultiSchemaInput, | ||
type OnSchemaUpdate, | ||
type SchemaConfig, | ||
type SchemaLoader, | ||
type SchemaLoaderResult, | ||
type SchemaOrigin, | ||
type SchemaRef, | ||
type SingleSchemaInput, | ||
TSError, | ||
TadaError, | ||
findTSConfigFile, | ||
getSchemaConfigForName, | ||
getURLConfig, | ||
@@ -137,2 +205,3 @@ load, | ||
loadFromURL, | ||
loadRef, | ||
minifyIntrospectionQuery as minifyIntrospection, | ||
@@ -139,0 +208,0 @@ outputIntrospectionFile, |
{ | ||
"name": "@gql.tada/internal", | ||
"version": "0.2.4", | ||
"version": "0.3.0-canary-0e6bf0c1d11563469036c776550836617d7cf4c6", | ||
"public": true, | ||
@@ -5,0 +5,0 @@ "description": "Internal logic for gql.tada’s CLI tool and GraphQLSP.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
376960
6238