Skip to content

Commit

Permalink
Update artifactDirectory docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rrdelaney committed Jan 31, 2022
1 parent 2c04783 commit 9573b7a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions website/docs/installation-and-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,26 @@ module.exports = {
};
```

### Why configured `artifactDirectory` ?
### Configuring `artifactDirectory`

Next.js's `/pages` directory cannot exclude Non React Component as default export file.
Next.js's `/pages` directory cannot include non-React components as default
export.

By default setting, The relay-compiler generates `*.graphql.ts` files that are co-located with the corresponding files containing graphql tags.

#### Generate `*.graphql.ts` files at out of `/pages` directory.
By default, the relay-compiler generates `*.graphql.ts` files that are
co-located with the corresponding files containing graphql tags. To fix this
configure `artifactDirectory` to emit to `src/queries/__generated__`:

```js:relay.config.js
module.exports = {
...
// ...
artifactDirectory: 'src/queries/__generated__',
}
```

See also [Type Emission | Relay](https://relay.dev/docs/guides/type-emission/#single-artifact-directory)

#### NOTE: You can keep `*.graphql.ts` files in `/pages` directory with `pageExtensions`

[next.config.js: Custom Page Extensions | Next.js](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions)

1. Add `pageExtensions: ['page.ts', 'page.tsx']` in next.config.js
2. Rename all page and api route files.
For more information please see the Relay
[type emission documentation](https://relay.dev/docs/guides/type-emission/#single-artifact-directory).
Alternatively you can keep `*.graphql.ts` files in `/pages` directory with
[`pageExtensions`](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions).

## Installing Relay Compiler

Expand Down

0 comments on commit 9573b7a

Please sign in to comment.