Comparing version 1.3.0-canary-0f13a4e1b1445000457b64432849b908decd66ea to 1.3.0-canary-1dc8cf5618ca4ba04f3a5ab83efa3e17a91426b7
@@ -893,3 +893,6 @@ import { Kind, OperationTypeNode, DocumentNode } from '@0no-co/graphql.web'; | ||
: true; | ||
type decorateFragmentDef<Document extends DocumentNodeLike> = Document['definitions'][0] extends { | ||
type decorateFragmentDef< | ||
Document extends DocumentNodeLike, | ||
isMaskingDisabled = false, | ||
> = Document['definitions'][0] extends { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
@@ -901,35 +904,40 @@ name: any; | ||
on: Document['definitions'][0]['typeCondition']['name']['value']; | ||
masked: isMaskedRec<Document['definitions'][0]['directives']>; | ||
masked: isMaskingDisabled extends true | ||
? false | ||
: isMaskedRec<Document['definitions'][0]['directives']>; | ||
} | ||
: void; | ||
type getFragmentsOfDocumentsRec<Documents> = Documents extends readonly [ | ||
type getFragmentsOfDocumentsRec<Documents, Fragments = {}> = Documents extends readonly [ | ||
infer Document, | ||
...infer Rest, | ||
] | ||
? (Document extends { | ||
[$tada.definition]?: any; | ||
} | ||
? Exclude<Document[$tada.definition], undefined> extends infer Definition extends | ||
FragmentDefDecorationLike | ||
? { | ||
[Name in Definition['fragment']]: { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: { | ||
kind: Kind.NAME; | ||
value: Definition['fragment']; | ||
}; | ||
typeCondition: { | ||
kind: Kind.NAMED_TYPE; | ||
? getFragmentsOfDocumentsRec< | ||
Rest, | ||
(Document extends { | ||
[$tada.definition]?: any; | ||
} | ||
? Exclude<Document[$tada.definition], undefined> extends infer Definition extends | ||
FragmentDefDecorationLike | ||
? { | ||
[Name in Definition['fragment']]: { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: { | ||
kind: Kind.NAME; | ||
value: Definition['on']; | ||
value: Definition['fragment']; | ||
}; | ||
typeCondition: { | ||
kind: Kind.NAMED_TYPE; | ||
name: { | ||
kind: Kind.NAME; | ||
value: Definition['on']; | ||
}; | ||
}; | ||
[$tada.ref]: makeFragmentRef<Document>; | ||
}; | ||
[$tada.ref]: makeFragmentRef<Document>; | ||
}; | ||
} | ||
: {} | ||
: {}) & | ||
getFragmentsOfDocumentsRec<Rest> | ||
: {}; | ||
} | ||
: {} | ||
: {}) & | ||
Fragments | ||
> | ||
: Fragments; | ||
type makeFragmentRef<Document> = Document extends { | ||
@@ -1265,13 +1273,18 @@ [$tada.definition]?: infer Definition; | ||
: never; | ||
type getFragmentMapRec<Definitions> = Definitions extends readonly [infer Definition, ...infer Rest] | ||
? (Definition extends { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: any; | ||
} | ||
? { | ||
[Name in Definition['name']['value']]: Definition; | ||
} | ||
: {}) & | ||
getFragmentMapRec<Rest> | ||
: {}; | ||
type getFragmentMapRec<Definitions, FragmentMap = {}> = Definitions extends readonly [ | ||
infer Definition, | ||
...infer Rest, | ||
] | ||
? getFragmentMapRec< | ||
Rest, | ||
Definition extends { | ||
kind: Kind.FRAGMENT_DEFINITION; | ||
name: any; | ||
} | ||
? { | ||
[Name in Definition['name']['value']]: Definition; | ||
} & FragmentMap | ||
: FragmentMap | ||
> | ||
: FragmentMap; | ||
@@ -1423,3 +1436,10 @@ type getInputObjectTypeRec< | ||
scalars?: ScalarsLike; | ||
disableMasking?: boolean; | ||
} | ||
/** Abstract type for internal configuration | ||
* @internal | ||
*/ | ||
interface AbstractConfig { | ||
isMaskingDisabled: boolean; | ||
} | ||
/** This is used to configure gql.tada with your introspection data and scalars. | ||
@@ -1457,3 +1477,3 @@ * | ||
interface setupSchema extends AbstractSetupSchema {} | ||
interface GraphQLTadaAPI<Schema extends IntrospectionLikeType> { | ||
interface GraphQLTadaAPI<Schema extends IntrospectionLikeType, Config extends AbstractConfig> { | ||
/** Function to create and compose GraphQL documents with result and variable types. | ||
@@ -1504,3 +1524,8 @@ * | ||
fragments?: Fragments | ||
): getDocumentNode<parseDocument<In>, Schema, getFragmentsOfDocumentsRec<Fragments>>; | ||
): getDocumentNode< | ||
parseDocument<In>, | ||
Schema, | ||
getFragmentsOfDocumentsRec<Fragments>, | ||
Config['isMaskingDisabled'] | ||
>; | ||
/** Function to validate the type of a given scalar or enum value. | ||
@@ -1544,6 +1569,9 @@ * | ||
} | ||
type schemaOfConfig<Setup extends AbstractSetupSchema> = mapIntrospection< | ||
type schemaOfSetup<Setup extends AbstractSetupSchema> = mapIntrospection< | ||
matchOr<IntrospectionQuery, Setup['introspection'], never>, | ||
matchOr<ScalarsLike, Setup['scalars'], {}> | ||
>; | ||
type configOfSetup<Setup extends AbstractSetupSchema> = { | ||
isMaskingDisabled: Setup['disableMasking'] extends true ? true : false; | ||
}; | ||
/** Setup function to create a typed `graphql` document function with. | ||
@@ -1576,3 +1604,4 @@ * | ||
declare function initGraphQLTada<const Setup extends AbstractSetupSchema>(): GraphQLTadaAPI< | ||
schemaOfConfig<Setup> | ||
schemaOfSetup<Setup>, | ||
configOfSetup<Setup> | ||
>; | ||
@@ -1596,2 +1625,3 @@ /** Alias to a GraphQL parse function returning an exact document type. | ||
} = {}, | ||
isMaskingDisabled = false, | ||
> = getDocumentType<Document, Introspection, Fragments> extends infer Result | ||
@@ -1603,3 +1633,3 @@ ? Result extends never | ||
getVariablesType<Document, Introspection>, | ||
decorateFragmentDef<Document> | ||
decorateFragmentDef<Document, isMaskingDisabled> | ||
> | ||
@@ -1689,14 +1719,14 @@ : never; | ||
: Data; | ||
type fragmentRefsOfFragmentsRec<Fragments extends readonly any[]> = Fragments extends readonly [ | ||
infer Fragment, | ||
...infer Rest, | ||
] | ||
? obj<makeFragmentRef<Fragment> & fragmentRefsOfFragmentsRec<Rest>> | ||
: {}; | ||
type resultOfFragmentsRec<Fragments extends readonly any[]> = Fragments extends readonly [ | ||
infer Fragment, | ||
...infer Rest, | ||
] | ||
? ResultOf<Fragment> & resultOfFragmentsRec<Rest> | ||
: {}; | ||
type fragmentRefsOfFragmentsRec< | ||
Fragments extends readonly any[], | ||
FragmentRefs = {}, | ||
> = Fragments extends readonly [infer Fragment, ...infer Rest] | ||
? fragmentRefsOfFragmentsRec<Rest, makeFragmentRef<Fragment> & FragmentRefs> | ||
: obj<FragmentRefs>; | ||
type resultOfFragmentsRec< | ||
Fragments extends readonly any[], | ||
Result = {}, | ||
> = Fragments extends readonly [infer Fragment, ...infer Rest] | ||
? resultOfFragmentsRec<Rest, ResultOf<Fragment> & Result> | ||
: Result; | ||
type fragmentOfTypeRec<Document extends makeDefinitionDecoration> = | ||
@@ -1847,3 +1877,3 @@ | readonly fragmentOfTypeRec<Document>[] | ||
>(_document: Document, data: Data): ResultOf<Document>; | ||
declare const graphql: GraphQLTadaAPI<schemaOfConfig<setupSchema>>; | ||
declare const graphql: GraphQLTadaAPI<schemaOfSetup<setupSchema>, configOfSetup<setupSchema>>; | ||
@@ -1850,0 +1880,0 @@ export { |
{ | ||
"name": "gql.tada", | ||
"description": "The spec-compliant & magical GraphQL query language engine in the TypeScript type system", | ||
"version": "1.3.0-canary-0f13a4e1b1445000457b64432849b908decd66ea", | ||
"version": "1.3.0-canary-1dc8cf5618ca4ba04f3a5ab83efa3e17a91426b7", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -39,3 +39,3 @@ "source": "./src/index.ts", | ||
"@0no-co/graphql.web": "^1.0.4", | ||
"@gql.tada/cli-utils": "0.1.0-canary-0f13a4e1b1445000457b64432849b908decd66ea" | ||
"@gql.tada/cli-utils": "0.1.0-canary-1dc8cf5618ca4ba04f3a5ab83efa3e17a91426b7" | ||
}, | ||
@@ -42,0 +42,0 @@ "public": true, |
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
106786
1971