-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
# Deepkit GraphQL | ||
Coming soon ... | ||
|
||
### Development | ||
<div align="center"> | ||
<img src="docs/logo/white.png#gh-dark-mode-only" width="25%" /> | ||
<img src="docs/logo/black.png#gh-light-mode-only" width="25%" /> | ||
<h1>Deepkit GraphQL</h1> | ||
</div> | ||
|
||
## Docs | ||
|
||
Check out the [documentation](https://deepkit-graphql.js.org) to get started. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
title: 'NestJS' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Queries | ||
|
||
## Mutations | ||
|
||
## Subscriptions | ||
|
||
## Fields | ||
|
||
## Context | ||
|
||
## Middleware | ||
|
||
## Parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Utility | ||
|
||
## Data | ||
|
||
## Validation | ||
|
||
## Annotations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: 'Annotations' | ||
--- | ||
|
||
## Excluded | ||
|
||
https://deepkit.io/documentation/runtime-types/types#excluded | ||
|
||
## MapName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
title: 'Data' | ||
--- | ||
|
||
<Info><b>Prerequisite</b>: Read the Deepkit section about [Type Annotations](https://deepkit.io/documentation/runtime-types/types).</Info> | ||
|
||
## ID | ||
The [`ID`](https://deepkit.io/documentation/runtime-types/types#uuid) type is represented as a `ID` scalar. | ||
<Info>`ID` is imported from `@deepkit-graphql/core`</Info> | ||
|
||
## MongoID | ||
The [`MongoID`](https://deepkit.io/documentation/runtime-types/types#mongoid) type is represented as a `ObjectID` scalar. | ||
<Info>`MongoID` is imported from `@deepkit/type`</Info> | ||
|
||
## UUID | ||
The [`UUID`](https://deepkit.io/documentation/runtime-types/types#uuid) type is represented as a `UUID` scalar. | ||
<Info>`UUID` is imported from `@deepkit/type`</Info> | ||
|
||
## Array | ||
An array is represented in GraphQL as a `List`. | ||
|
||
## Date | ||
The `Date` type is serialized as an ISO 8601 formatted string, and represented as a `DateTime` scalar. | ||
|
||
<Info>An ISO 8601 formatted string looks like `2007-12-03T10:15:30Z`</Info> | ||
|
||
## string | ||
A string is represented as a GraphQL `String` scalar. | ||
|
||
## boolean | ||
A boolean is represented as a GraphQL `Boolean` scalar. | ||
|
||
## float | ||
The [`float`](https://deepkit.io/documentation/runtime-types/types#float) type is represented as a `Float` scalar. | ||
<Info>`float` is imported from `@deepkit/type`</Info> | ||
|
||
### Annotations | ||
|
||
#### Positive | ||
The `Positive` annotation for `float` is represented as a [`PositiveFloat`](https://the-guild.dev/graphql/scalars/docs/scalars/positive-float) scalar. | ||
|
||
<Info>`Positive` is imported from `@deepkit/type`</Info> | ||
|
||
#### Negative | ||
The `Negative` annotation for `float` is represented as a [`NegativeFloat`](https://the-guild.dev/graphql/scalars/docs/scalars/negative-float) scalar. | ||
|
||
<Info>`Negative` is imported from `@deepkit/type`</Info> | ||
|
||
## number | ||
The `number` type is not a valid type, because it cannot be represented. | ||
|
||
## integer | ||
The [`integer`](https://deepkit.io/documentation/runtime-types/types#integer) type is represented as a [`Int`](https://graphql.com/learn/scalars-objects-lists/#the-int-type) scalar. | ||
|
||
<Info>`integer` is imported from `@deepkit/type`</Info> | ||
|
||
### Annotations | ||
|
||
#### Positive | ||
The [`Positive`](https://deepkit.io/documentation/runtime-types/types#integer) annotation for `integer` is represented as a [`PositiveInt`](https://the-guild.dev/graphql/scalars/docs/scalars/positive-int) scalar. | ||
|
||
<Info>`Positive` is imported from `@deepkit/type`</Info> | ||
|
||
#### Negative | ||
The `Negative` annotation for `integer` is represented as a [`NegativeInt`](https://the-guild.dev/graphql/scalars/docs/scalars/negative-int) scalar. | ||
|
||
<Info>`Negative` is imported from `@deepkit/type`</Info> | ||
|
||
## bigint | ||
The [`bigint`](https://deepkit.io/documentation/runtime-types/types#bigint) type is represented as a [`BigInt`](https://the-guild.dev/graphql/scalars/docs/scalars/big-int) scalar. | ||
|
||
### Annotations | ||
|
||
#### BinaryBigInt | ||
The [`BinaryBigInt`](https://deepkit.io/documentation/runtime-types/types#bigint) type is represented as a `BinaryBigInt` scalar. | ||
<Info>`BinaryBigInt` is imported from `@deepkit/type`</Info> | ||
|
||
#### SignedBinaryBigInt | ||
The [`SignedBinaryBigInt`](https://deepkit.io/documentation/runtime-types/types#bigint) type is represented as a `SignedBinaryBigInt` scalar. | ||
<Info>`SignedBinaryBigInt` is imported from `@deepkit/type`</Info> | ||
|
||
## ArrayBuffer | ||
The [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) type is represented as a `Byte` scalar. | ||
|
||
## Uint8Array | ||
The [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) type is represented as a `Byte` scalar. | ||
|
||
## Union | ||
|
||
## Intersection | ||
|
||
## Excluded | ||
|
||
## MapName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: 'Inline' | ||
description: 'In TypeScript, an inline type refers to a type definition declared directly at the point of use without assigning it a separate name.' | ||
--- | ||
|
||
The names of GraphQL object types corresponding to TypeScript inline types are generated by excluding any non-alphanumeric characters. | ||
|
||
<Info>For comparison, see [referenced types](/concepts/types/referenced).</Info> | ||
|
||
## Example | ||
|
||
```ts | ||
interface User { | ||
id: string; | ||
email: string; | ||
} | ||
|
||
@graphql.resolver() | ||
class UserResolver { | ||
@graphql.query() | ||
getUserId(): Pick<User, 'id'> { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
In this example, the return type `Pick<User, 'id'>` of the `getUserId` query is not a valid object type name. | ||
To resolve this, non-alphanumeric characters are excluded, resulting in the generated name `PickUserid`. | ||
|
||
```graphql | ||
type PickUserid { | ||
id: String! | ||
} | ||
|
||
type Query { | ||
getUserId: PickUserid | ||
} | ||
``` | ||
|
||
This ensures that the generated name is compatible with the GraphQL naming requirements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: 'Overview' | ||
--- | ||
|
||
There is no code distinction between [Object](https://graphql.org/graphql-js/object-types/) and [Input](https://graphql.org/learn/schema/#input-types) types. | ||
|
||
It depends entirely on where those types are being used in the code. | ||
|
||
For example, TypeScript object type literals used in query/mutation parameters will be GraphQL Input types, whereas the return type of those resolvers will be GraphQL Object types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: 'Referenced' | ||
description: 'In TypeScript, a referenced type is a type definition declared with a specific name, allowing it to be referred to or reused elsewhere in the code.' | ||
--- | ||
|
||
Referenced type names will be used as the name for the generated GraphQL object type. | ||
|
||
<Info>For comparison, see [inline types](/concepts/types/inline).</Info> | ||
|
||
## Example | ||
|
||
```ts | ||
interface User { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
type UserWithoutName = Omit<User, 'name'>; | ||
|
||
@graphql.resolver() | ||
class UserResolver { | ||
@graphql.query() | ||
getUserId(): UserWithoutName { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
In this example, the `UserWithoutName` referenced type is utilized as the object type name instead of the automatically generated inline type name `OmitUsername` derived from `Omit<User, 'name'>`. | ||
|
||
```graphql | ||
type UserWithoutName { | ||
id: String! | ||
} | ||
|
||
type Query { | ||
getUserId: UserWithoutName | ||
} | ||
``` | ||
|
||
This showcases how the explicitly named referenced type contributes to the clarity and semantic coherence of the generated GraphQL object type. |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Deepkit GraphQL can be used standalone in any existing setup that supports custom graphql object types and graphql contexts | ||
|
||
Here's an example using Apollo Server | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Prerequisites | ||
A basic understanding of [TypeScript](https://www.typescriptlang.org), [GraphQL](https://graphql.org) and [Deepkit](https://deepkit.io) | ||
|
||
|
||
Install the required dependencies | ||
<Tabs> | ||
<Tab title="npm"> | ||
```sh | ||
$ npm install @deepkit-graphql/core graphql | ||
``` | ||
</Tab> | ||
<Tab title="yarn"> | ||
```sh | ||
$ yarn add @deepkit-graphql/core graphql | ||
``` | ||
</Tab> | ||
<Tab title="pnpm"> | ||
```sh | ||
$ pnpm add @deepkit-graphql/core graphql | ||
``` | ||
</Tab> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
title: 'NestJS' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters