Comparing version 1.0.0 to 1.0.1-canary-7986c5421362da3ff161beb2a2ed90c51fa04b27
@@ -5,6 +5,6 @@ import { | ||
DocumentNode, | ||
FragmentSpreadNode, | ||
InlineFragmentNode, | ||
FieldNode, | ||
NameNode, | ||
FragmentSpreadNode, | ||
InlineFragmentNode, | ||
TypeNode, | ||
@@ -1021,6 +1021,6 @@ } from '@0no-co/graphql.web'; | ||
? Directive['name']['value'] extends 'include' | 'skip' | 'defer' | ||
? false | ||
? true | ||
: isOptionalRec<Rest> | ||
: isOptionalRec<Rest> | ||
: true; | ||
: false; | ||
type getFieldAlias<Node extends FieldNode> = Node['alias'] extends undefined | ||
@@ -1090,3 +1090,3 @@ ? Node['name']['value'] | ||
} | ||
? Type['possibleTypes'] | ||
? Type['name'] | Type['possibleTypes'] | ||
: Type['name']; | ||
@@ -1100,41 +1100,5 @@ type getSelection< | ||
}, | ||
> = obj< | ||
getFieldsSelectionRec<Selections, Type, Introspection, Fragments> & | ||
getFragmentsSelection<Selections, Type, Introspection, Fragments> | ||
>; | ||
type getFieldsSelectionRec< | ||
> = obj<getPossibleTypesSelection<Selections, Type, Introspection, Fragments>>; | ||
type _getPossibleTypeSelectionRec< | ||
Selections extends readonly unknown[], | ||
Type extends ObjectLikeType, | ||
Introspection extends IntrospectionLikeType, | ||
Fragments extends { | ||
[name: string]: any; | ||
}, | ||
> = Selections extends readonly [infer Selection, ...infer Rest] | ||
? (Selection extends FieldNode | ||
? isOptionalRec<Selection['directives']> extends true | ||
? { | ||
[Prop in getFieldAlias<Selection>]: Selection['name']['value'] extends '__typename' | ||
? getTypenameOfType<Type> | ||
: unwrapType$1< | ||
Type['fields'][Selection['name']['value']]['type'], | ||
Selection['selectionSet'], | ||
Introspection, | ||
Fragments | ||
>; | ||
} | ||
: { | ||
[Prop in getFieldAlias<Selection>]?: Selection['name']['value'] extends '__typename' | ||
? getTypenameOfType<Type> | ||
: unwrapType$1< | ||
Type['fields'][Selection['name']['value']]['type'], | ||
Selection['selectionSet'], | ||
Introspection, | ||
Fragments | ||
>; | ||
} | ||
: {}) & | ||
getFieldsSelectionRec<Rest, Type, Introspection, Fragments> | ||
: {}; | ||
type _getFragmentsSelectionRec< | ||
Selections extends readonly unknown[], | ||
PossibleType extends string, | ||
@@ -1150,5 +1114,5 @@ Type extends ObjectLikeType, | ||
ObjectLikeType | ||
? PossibleType extends Subtype['name'] | getTypenameOfType<Subtype> | ||
? PossibleType extends getTypenameOfType<Subtype> | ||
? | ||
| (isOptionalRec<Node['directives']> extends true ? never : {}) | ||
| (isOptionalRec<Node['directives']> extends true ? {} : never) | ||
| getFragmentSelection<Node, Subtype, Introspection, Fragments> | ||
@@ -1159,6 +1123,28 @@ : {} | ||
: {} | ||
: {}) & | ||
_getFragmentsSelectionRec<Rest, PossibleType, Type, Introspection, Fragments> | ||
: Node extends FieldNode | ||
? isOptionalRec<Node['directives']> extends true | ||
? { | ||
[Prop in getFieldAlias<Node>]?: Node['name']['value'] extends '__typename' | ||
? PossibleType | ||
: unwrapType$1< | ||
Type['fields'][Node['name']['value']]['type'], | ||
Node['selectionSet'], | ||
Introspection, | ||
Fragments | ||
>; | ||
} | ||
: { | ||
[Prop in getFieldAlias<Node>]: Node['name']['value'] extends '__typename' | ||
? PossibleType | ||
: unwrapType$1< | ||
Type['fields'][Node['name']['value']]['type'], | ||
Node['selectionSet'], | ||
Introspection, | ||
Fragments | ||
>; | ||
} | ||
: {}) & | ||
_getPossibleTypeSelectionRec<Rest, PossibleType, Type, Introspection, Fragments> | ||
: {}; | ||
type getFragmentsSelection< | ||
type getPossibleTypesSelection< | ||
Selections extends readonly unknown[], | ||
@@ -1175,3 +1161,3 @@ Type extends ObjectLikeType, | ||
? objValues<{ | ||
[PossibleType in Type['possibleTypes']]: _getFragmentsSelectionRec< | ||
[PossibleType in Type['possibleTypes']]: _getPossibleTypeSelectionRec< | ||
Selections, | ||
@@ -1188,3 +1174,3 @@ PossibleType, | ||
} | ||
? _getFragmentsSelectionRec<Selections, Type['name'], Type, Introspection, Fragments> | ||
? _getPossibleTypeSelectionRec<Selections, Type['name'], Type, Introspection, Fragments> | ||
: {}; | ||
@@ -1191,0 +1177,0 @@ type getOperationSelectionType< |
{ | ||
"name": "gql.tada", | ||
"description": "The spec-compliant & magical GraphQL query language engine in the TypeScript type system", | ||
"version": "1.0.0", | ||
"version": "1.0.1-canary-7986c5421362da3ff161beb2a2ed90c51fa04b27", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -6,0 +6,0 @@ "source": "./src/index.ts", |
@@ -47,33 +47,4 @@ <div align="center"> | ||
```ts | ||
import { graphql } from 'gql.tada'; | ||
import { myIntrospectionQuery } from './fixtures/introspection'; | ||
<img width="100%" alt="Code Editor showing GraphQL queries being edited with gql.tada and GraphLSP" src="https://github.com/0no-co/gql.tada/blob/277ce424a747522ef2ca0d398b113f4f285eb595/website/public/demo-code.png?raw=true" /> | ||
// We can declare our introspected schema once globally | ||
declare module 'gql.tada' { | ||
interface setupSchema { | ||
introspection: typeof myIntrospectionQuery; | ||
} | ||
} | ||
// Creates fragment documents | ||
const fragment = graphql(` | ||
fragment HelloWorld extends Query { | ||
hello | ||
world | ||
} | ||
`); | ||
// Creates queries, optionally accepting a list of fragments for fragment spreads | ||
const query = graphql( | ||
` | ||
{ | ||
hello | ||
...HelloWorld | ||
} | ||
`, | ||
[fragment] | ||
); | ||
``` | ||
## 📦 [Releases](https://github.com/0no-co/gql.tada/releases) | ||
@@ -80,0 +51,0 @@ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
86960
1727
2
61