@gql.tada/internal
Advanced tools
Comparing version 0.2.4 to 0.3.0-canary-3c09253dc57ece41320907f966ceceb5265b2b49
# @gql.tada/internal | ||
## 0.3.0-canary-3c09253dc57ece41320907f966ceceb5265b2b49 | ||
### 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)) | ||
## 0.2.4 | ||
@@ -4,0 +11,0 @@ |
@@ -5,4 +5,7 @@ import { IntrospectionQuery, GraphQLSchema } from 'graphql'; | ||
interface IntrospectionResult extends IntrospectionQuery { | ||
name: string | undefined; | ||
} | ||
interface SchemaLoaderResult { | ||
introspection: IntrospectionQuery; | ||
introspection: IntrospectionResult; | ||
schema: GraphQLSchema; | ||
@@ -12,9 +15,21 @@ } | ||
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 SchemaRef<Result = SchemaLoaderResult | null> { | ||
/** Starts automatically updating the ref */ | ||
autoupdate(): () => void; | ||
/** Loads the initial result for the schema */ | ||
load(): Promise<SchemaRef<SchemaLoaderResult>>; | ||
current: Result; | ||
multi: { | ||
[name: string]: Result; | ||
}; | ||
version: number; | ||
} | ||
type SchemaOrigin = | ||
@@ -28,2 +43,3 @@ | string | ||
interface LoadFromSDLConfig { | ||
name?: string; | ||
assumeValid?: boolean; | ||
@@ -35,2 +51,3 @@ file: string; | ||
interface LoadFromURLConfig { | ||
name?: string; | ||
url: URL | string; | ||
@@ -46,4 +63,3 @@ headers?: HeadersInit; | ||
} | null; | ||
interface LoadConfig { | ||
origin: SchemaOrigin; | ||
interface BaseLoadConfig { | ||
rootPath?: string; | ||
@@ -53,3 +69,17 @@ fetchInterval?: number; | ||
} | ||
interface LoadConfig extends BaseLoadConfig { | ||
origin: SchemaOrigin; | ||
} | ||
declare function load(config: LoadConfig): SchemaLoader; | ||
type SingleSchema = { | ||
name?: string; | ||
schema: SchemaOrigin; | ||
}; | ||
type MultiSchema = { | ||
schemas?: SingleSchema[]; | ||
}; | ||
declare function loadRef( | ||
input: SingleSchema | MultiSchema | (SingleSchema & MultiSchema), | ||
config?: BaseLoadConfig | ||
): SchemaRef; | ||
@@ -66,3 +96,7 @@ declare class TSError extends Error { | ||
interface GraphQLSPConfig { | ||
interface BaseConfig { | ||
template?: string; | ||
} | ||
interface SchemaConfig { | ||
name?: string; | ||
schema: SchemaOrigin; | ||
@@ -72,5 +106,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; | ||
@@ -107,5 +154,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; | ||
@@ -117,3 +168,3 @@ interface OutputIntrospectionFileOptions { | ||
declare function outputIntrospectionFile( | ||
introspection: IntrospectionQuery | string, | ||
introspection: IntrospectionQuery | IntrospectionResult, | ||
opts: OutputIntrospectionFileOptions | ||
@@ -123,12 +174,18 @@ ): string; | ||
export { | ||
type BaseConfig, | ||
type BaseLoadConfig, | ||
type GraphQLSPConfig, | ||
type IntrospectionResult, | ||
type LoadConfig, | ||
type LoadConfigResult, | ||
type OnSchemaUpdate, | ||
type SchemaConfig, | ||
type SchemaLoader, | ||
type SchemaLoaderResult, | ||
type SchemaOrigin, | ||
type SchemaRef, | ||
TSError, | ||
TadaError, | ||
findTSConfigFile, | ||
getSchemaConfigForName, | ||
getURLConfig, | ||
@@ -139,2 +196,3 @@ load, | ||
loadFromURL, | ||
loadRef, | ||
minifyIntrospectionQuery as minifyIntrospection, | ||
@@ -141,0 +199,0 @@ outputIntrospectionFile, |
{ | ||
"name": "@gql.tada/internal", | ||
"version": "0.2.4", | ||
"version": "0.3.0-canary-3c09253dc57ece41320907f966ceceb5265b2b49", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
372726
6159