Skip to content

Commit

Permalink
chore(docs): add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sa committed Feb 6, 2024
1 parent 8411c21 commit af87e32
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 9 deletions.
12 changes: 9 additions & 3 deletions README.md
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.
3 changes: 3 additions & 0 deletions docs/comparisons/nestjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: 'NestJS'
---
13 changes: 13 additions & 0 deletions docs/concepts/resolvers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Queries

## Mutations

## Subscriptions

## Fields

## Context

## Middleware

## Parent
7 changes: 7 additions & 0 deletions docs/concepts/types.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Utility

## Data

## Validation

## Annotations
9 changes: 9 additions & 0 deletions docs/concepts/types/annotations.mdx
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
94 changes: 94 additions & 0 deletions docs/concepts/types/data.mdx
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
40 changes: 40 additions & 0 deletions docs/concepts/types/inline.mdx
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.
9 changes: 9 additions & 0 deletions docs/concepts/types/overview.mdx
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.
41 changes: 41 additions & 0 deletions docs/concepts/types/referenced.mdx
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 added docs/concepts/types/utility.mdx
Empty file.
Empty file.
Empty file added docs/guides/apollo.mdx
Empty file.
4 changes: 4 additions & 0 deletions docs/guides/standalone.mdx
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 added docs/guides/yoga.mdx
Empty file.
22 changes: 22 additions & 0 deletions docs/introduction.mdx
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>
3 changes: 3 additions & 0 deletions docs/migrations/nestjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: 'NestJS'
---
38 changes: 32 additions & 6 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,46 @@
"name": "Changelog",
"icon": "list",
"url": "https://github.com/marcus-sa/deepkit-graphql/releases"
},
{
"name": "Community",
"icon": "discord",
"url": "https://discord.gg/U24mryk7Wq"
}
],
"navigation": [
{
"group": "Home",
"pages": ["introduction", "quickstart"]
},
{
"group": "Concepts",
"pages": [
{
"group": "Types",
"pages": [
"concepts/types/overview",
"concepts/types/inline",
"concepts/types/referenced",
"concepts/types/data",
"concepts/types/utility",
"concepts/types/annotations",
"concepts/types/validation"
]
},
"concepts/resolvers"
]
},
{
"group": "Guides",
"pages": ["guides/apollo", "guides/yoga", "guides/standalone"]
},
{
"group": "Migrations",
"pages": ["migrations/nestjs"]
},
{
"group": "Comparisons",
"pages": ["comparisons/nestjs"]
}
],
"footerSocials": {
"github": "https://github.com/marcus-sa/deepkit-graphql"
"github": "https://github.com/marcus-sa/deepkit-graphql",
"discord": "https://discord.gg/U24mryk7Wq"
}
}

0 comments on commit af87e32

Please sign in to comment.