Skip to content

Commit

Permalink
chore(docs): tweak nexus module intro
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Jul 27, 2020
1 parent 4fc1baf commit 7c84c15
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions website/content/040-api/01-nexus/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ codeStyle: true

## `import ... from 'nexus'`

This section is about the main module of the `nexus` pacakge. Of all Nexus' modules this is the one you'll find yourself using the most in a Nexus projet. The main `nexus` module exports an application singleton. It is available as the default module export. The primary components of the application are exposed via properties on the application object. For convenience these components are also exposed as named exports. If you do not like long property chains you might prefer imported the named exports. See examples of either style below.
This section is about the main module of the `nexus` pacakge. Of all Nexus' modules this is the one you'll find yourself using the most in a Nexus projet. The main `nexus` module exports an application singleton. It is available as the default module export. The primary components of the application are exposed via properties on the application object. For convenience these components are also exposed as named exports. If you do not like long property chains you might prefer imported the named exports (see examples of either style later in this page). Each named export is documented on its own page. Each named export has a corollary guide page as well. Guides take time to explain concepts and motivations. The API docs focus only on dry technical details of the API.

> ##### A Word About Autocomplete
>
> Whichever import style you go with know that you can benefit from [TypeScript's auto-import feature](https://code.visualstudio.com/docs/languages/typescript#_auto-imports). To import the defualt export by name automatically you need to use the same identifier that we use internally. That identifier is `app`. Type that anywhere and you should see the option to auto-import the default export from `nexus`.
Each named export is documented on its own page. Each named export has a corollary guide page.

### Example of importing default export

```ts
import app from 'nexus'

app.log.info('hello world')
app.on.start(() => {
app.log.info('Hello World!')
})

app.settings.change({
server: {
Expand All @@ -29,17 +29,19 @@ app.settings.change({

app.schema.queryType({
definition(t) {
t.field('foo', { type: 'String' })
t.string('foo', () => 'bar')
},
})
```

### Example of importing named exports

```ts
import { schema, settings, log } from 'nexus'
import { schema, settings, log, on } from 'nexus'

log.info('hello world')
on.start(() => {
log.info('Hello World!')
})

settings.change({
server: {
Expand All @@ -49,7 +51,7 @@ settings.change({

schema.queryType({
definition(t) {
t.field('foo', { type: 'String' })
t.string('foo', () => 'bar')
},
})
```
Expand Down

0 comments on commit 7c84c15

Please sign in to comment.