Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Mar 14, 2019
1 parent a2c92c0 commit 9584a05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions docs/3-how_to_use.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ A file to define the context of your GraphQL server. It must default export a fu

```ts
// src/context.ts
import { context } from "yoga";
import { yogaContext } from "yoga";
import { orm } from "./my-orm";

// `context` is an optional helper to provide type-safety and autocompletion
export default context(({ req }) => ({ req, orm }));
export default yogaContext(({ req }) => ({ req, orm }));
```

**`express.ts` (optional)**
Expand All @@ -65,11 +65,11 @@ A file to access the underlying express instance (and use middlewares, expose we

```ts
// src/express.ts
import { express } from "yoga";
import { yogaExpress } from "yoga";
import { middleware } from "my-express-middleware";

// `express` is an optional helper to provide type-safety and autocompletion
export default express(app => {
export default yogaExpress(app => {
// Define any express related logic using the injected `app` express instance
app.use(middleware);
// app.get('/login', ...)
Expand Down
20 changes: 11 additions & 9 deletions docs/4-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ Most of the opinionated conventions on which Yoga is built can be overriden at a

A `yoga.config.ts` file can be created at the root of your project. It must default export an object containing one of the following properties

| Key | Type | Default | Note |
| --------------- | ------------------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resolversPath` | `string` | `./src/graphql/` | Path to the directory where your resolvers are defined. **If provided, path has to exist.** |
| `contextPath` | `string` | `./src/context.ts` | Path to your `context.ts` file. **If provided, path has to exist.** |
| `ejectFilePath` | `string` | `./src/server.ts` | Path to an `server.ts` file to eject from default configuration `yoga.config.ts`. When provided, all other configuration properties are ignored and should be configured programatically. **If provided, path has to exist.** |
| `output` | `InputOutputFilesConfig` | See below. | Configuration for the outputted files (schema, typings, etc). |
| `prisma` | `InputPrismaConfig` | See below. | Configuration for the Prisma integration. |
| Key | Type | Default | Note |
| --------------- | ------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resolversPath` | `string` | `./src/graphql/` | Path to the directory where your resolvers are defined |
| `contextPath` | `string` | `./src/context.ts` | Path to a file where you can define your GraphQL server context |
| `expressPath` | `string` | `./src/express.ts` | Path to a file where you can access the underlying express instance |
| `typesPath` | `string` | `./src/types.ts` | Path to a file where you can override nexus typescript types used to annotate your GraphQL types |
| `ejectFilePath` | `string` | `./src/server.ts` | Path to a file to eject from the default configuration `yoga.config.ts`. When provided, all other configuration properties are ignored and should be configured programatically. |
| `output` | `InputOutputFilesConfig` | See below. | Configuration for the outputted files (schema, typings, etc). |
| `prisma` | `InputPrismaConfig` | See below. | Configuration for the Prisma integration. |

#### InputOutputFilesConfig

Expand All @@ -39,10 +41,10 @@ A `yoga.config.ts` file that would use all the _default_ options would look like

```ts
// yoga.config.ts
import { config } from "yoga";
import { yogaConfig } from "yoga";

// `config` is just an optional helper to provide type-safety and auto-completion
export default config({
export default yogaConfig({
resolversPath: "./src/graphql/",
contextPath: "./src/context.ts",
ejectFilePath: "./src/server.ts",
Expand Down

0 comments on commit 9584a05

Please sign in to comment.