Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Mar 14, 2019
1 parent 93135db commit 13cd004
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: integrate-with-apollo-server
title: Integrate With Apollo-Server
sidebar_label: Apollo-Server
sidebar_label: Integrate With Apollo-Server
---

GraphQLModules comes with a built-in support for **[Apollo-Server](https://www.apollographql.com/docs/apollo-server/getting-started.html)**.
Expand All @@ -18,14 +18,15 @@ Then, create a new instance of `ApolloServer`, and use your `GraphQLModule` inst
import { GraphQLModule } from '@graphql-modules/core';
import { ApolloServer } from 'apollo-server';

const { schema, context } = new GraphQLModule({
const AppModule = new GraphQLModule({
/*...*/
});

const server = new ApolloServer({
schema,
context,
/*...*/
modules: [
AppModule
],
context: session => ({ session }),
});

server.listen().then(({ url }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: implement-your-providers
id: implement-providers
title: Implement Your Providers
sidebar_label: Implement Your Providers
sidebar_label: Implement Providers
---

When your app grows and becomes more complex, you can use **Providers** (it's just a class...) to implement your resolvers' logic.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: implement-your-resolvers
id: implement-resolvers
title: Implement Your Resolvers
sidebar_label: Implement Your Resolvers
sidebar_label: Implement Resolvers
---

GraphQL Modules let you implement your GraphQL resolvers in a normal way, just like any other GraphQL application.
Expand Down
36 changes: 36 additions & 0 deletions docs/introduction/implement-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
id: implement-server
title: Implement Your Server
sidebar_label: Implement Server
---

To get started, add `express` amd `express-graphql` to your app:

```bash
yarn add express express-graphql
```

Then,

```typescript
import { GraphQLModule, buildAppContext } from '@graphql-modules/core';
import * as express from 'express';
import * as graphqlHTTP from 'express-graphql';

const { schema } = new GraphQLModule({
/*...*/
});

const app = express();

app.use('/graphql', graphqlHTTP({
schema,
graphiql: true
});

app.listen(4000);
```
> To test your server, run `ts-node index.ts` and try to open `http://localhost:4000/`, you should see the **[GraphiQL](https://github.com/graphql/graphiql)** UI.

> If you want to use **[Apollo-Server](https://www.apollographql.com/docs/apollo-server/getting-started.html)** check **Integrate with Apollo Server** section
1 change: 0 additions & 1 deletion packages/core/cjs/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/src/graphql-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ export class GraphQLModule<Config = any, Session = any, Context = any> {
if (typeof appContext === 'undefined') {
throw new IllegalResolverInvocationError(resolverPath, this.name, `Module Context hasn't been passed!`);
}
const session = info.session || appContext.session;
const session = info.session || appContext.session || appContext;
info.session = session;
if (typeof session === 'undefined' || 'connection' in session && !('session' in session['connection']['context'])) {
// tslint:disable-next-line:no-console
Expand Down
1 change: 0 additions & 1 deletion packages/di/cjs/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/graphql-modules/cjs/index.js

This file was deleted.

7 changes: 4 additions & 3 deletions website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"introduction/getting-started",
"introduction/modules",
"introduction/your-first-module",
"introduction/integrate-with-apollo-server",
"introduction/implement-your-resolvers",
"introduction/implement-your-providers",
"introduction/implement-server",
"introduction/implement-resolvers",
"introduction/implement-providers",
"introduction/dependencies",
"introduction/dependency-injection",
"introduction/configuration",
Expand All @@ -23,6 +23,7 @@
],
"Guides": [
"guides/development-environment",
"guides/integrate-with-apollo-server",
"guides/load-your-schema",
"guides/communication-between-modules",
"guides/microservices",
Expand Down

0 comments on commit 13cd004

Please sign in to comment.