Skip to content

Commit

Permalink
chore(docs): integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sa committed Feb 7, 2024
1 parent 0f735d2 commit 883690d
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 39 deletions.
14 changes: 3 additions & 11 deletions docs/concepts/types/data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ The [`UUID`](https://deepkit.io/documentation/runtime-types/types#uuid) type is
<Info>`UUID` is imported from `@deepkit/type`</Info>

## Array
An array is represented in GraphQL as a `List`.
The `Array` type is represented 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.
The `string` type is represented as a `String` scalar.

## boolean
A boolean is represented as a GraphQL `Boolean` scalar.
The `boolean` type is is represented as a `Boolean` scalar.

## float
The [`float`](https://deepkit.io/documentation/runtime-types/types#float) type is represented as a `Float` scalar.
Expand Down Expand Up @@ -84,11 +84,3 @@ The [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## 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
11 changes: 11 additions & 0 deletions docs/concepts/types/utility.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


## Union

## Intersection

## Excluded
<Info>`Excluded` is imported from `@deepkit/type`</Info>

## MapName
<Info>`MapName` is imported from `@deepkit/type`</Info>
Empty file removed docs/guides/apollo.mdx
Empty file.
4 changes: 0 additions & 4 deletions docs/guides/standalone.mdx

This file was deleted.

Empty file removed docs/guides/yoga.mdx
Empty file.
34 changes: 34 additions & 0 deletions docs/integrations/apollo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: 'Apollo'
description: 'Use [Apollo](https://www.apollographql.com/docs/apollo-server/) as the underlying GraphQL server'
---

## 1. Installation
<Tabs>
<Tab title="npm">
```sh
$ npm install @deepkit-graphql/apollo
```
</Tab>
<Tab title="yarn">
```sh
$ yarn add @deepkit-graphql/apollo
```
</Tab>
<Tab title="pnpm">
```sh
$ pnpm add @deepkit-graphql/apollo
```
</Tab>
</Tabs>

## 2. Setup
```typescript
import { ApolloGraphQLModule } from '@deepkit-graphql/apollo';

await new App({
imports: [new ApolloGraphQLModule()],
}).run();
```
<Info>Remove `GraphQLModule` if it's already imported</Info>

119 changes: 119 additions & 0 deletions docs/integrations/standalone.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: 'Standalone'
---
Deepkit GraphQL seamlessly integrates into any existing setup that supports a custom GraphQL schema and context.

Here's an example using [Apollo Server](https://www.apollographql.com/docs/apollo-server):
<CodeGroup>
```typescript main.ts
import { ApolloServer } from 'apollo-server';

import { schema } from './schema';
import { injectorContext } from './app';

await new ApolloServer({
schema,
context: () => {
const gqlInjectorContext = injectorContext.createChildScope('graphql');
// You can do whatever you want with the GraphQL injector context here
return {
injectorContext: gqlInjectorContext,
};
},
}).listen();
```

```typescript schema.ts
import * as user from './user/types';

export const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: () => ({
user: user.queries,
}),
}),
mutation: new GraphQLObjectType({
name: 'Mutation',
fields: () => ({
user: user.mutations,
}),
}),
});
```

```typescript app.ts
import { App } from '@deepkit/app';
import { GraphQLModule, Resolvers, TypesBuilder } from '@deepkit-graphql/core';

import { UserModule } from './user/user.module';

const gqlModule = new GraphQLModule();

export const app = new App({
imports: [gqlModule, new UserModule()],
});

export const injectorContext = app.serviceContainer.getInjectorContext();

export const builder = new TypesBuilder(gqlModule.resolvers);
```

```typescript user/user.module.ts
import { createModule } from '@deepkit/app';

import { UserResolver } from './user.resolver';

export class UserModule extends createModule({
controllers: [UserResolver],
}) {}
```

```typescript user/user.resolver.ts
import { graphql } from '@deepkit-graphql/core';

export interface User {
// ...
}

@graphql.resolver<User>()
export class UserResolver {
@graphql.query()
get(): Promise<User> {
// ...
}

@graphql.mutation()
create(): Promise<User> {
// ...
}
}
```

```typescript user/types.ts
import { GraphQLObjectType } from 'graphql';

import { builder } from '../app';
import { UserResolver } from './user.resolver';

export const queries = {
type: new GraphQLObjectType({
name: 'UserQueries',
fields: () =>
builder.generateQueryResolverFields({
controller: UserResolver,
}),
}),
};

export const mutations = {
type: new GraphQLObjectType({
name: 'UserMutations',
fields: () =>
builder.generateMutationResolverFields({
controller: UserResolver,
}),
}),
};
```
</CodeGroup>
33 changes: 33 additions & 0 deletions docs/integrations/yoga.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: 'Yoga'
description: 'Use [Yoga](https://the-guild.dev/graphql/yoga-server) as the underlying GraphQL server'
---

## 1. Installation
<Tabs>
<Tab title="npm">
```sh
$ npm install @deepkit-graphql/yoga
```
</Tab>
<Tab title="yarn">
```sh
$ yarn add @deepkit-graphql/yoga
```
</Tab>
<Tab title="pnpm">
```sh
$ pnpm add @deepkit-graphql/yoga
```
</Tab>
</Tabs>

## 2. Setup
```typescript
import { YogaGraphQLModule } from '@deepkit-graphql/yoga';

await new App({
imports: [new YogaGraphQLModule()],
}).run();
```
<Info>Remove `GraphQLModule` if it's already imported</Info>
24 changes: 3 additions & 21 deletions docs/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
## Prerequisites
A basic understanding of [TypeScript](https://www.typescriptlang.org), [GraphQL](https://graphql.org) and [Deepkit](https://deepkit.io)
Deepkit GraphQL is a revolutionary new way to build GraphQL server applications by utilizing Deepkit [Runtime Types](https://deepkit.io/library/type).


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>
#### Why do we need another library for GraphQL server applications?
TODO
5 changes: 2 additions & 3 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@
"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": "Integrations",
"pages": ["integrations/apollo", "integrations/yoga", "integrations/standalone"]
},
{
"group": "Migrations",
Expand Down
21 changes: 21 additions & 0 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 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>

0 comments on commit 883690d

Please sign in to comment.