-
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
11 changed files
with
226 additions
and
39 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
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,11 @@ | ||
|
||
|
||
## Union | ||
|
||
## Intersection | ||
|
||
## Excluded | ||
<Info>`Excluded` is imported from `@deepkit/type`</Info> | ||
|
||
## MapName | ||
<Info>`MapName` is imported from `@deepkit/type`</Info> |
Empty file.
This file was deleted.
Oops, something went wrong.
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,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> | ||
|
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,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> |
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,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> |
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,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 |
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
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,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> |