From 7c84c1558ca075daec91a02c024d0079c3e52b45 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sun, 26 Jul 2020 23:42:31 -0400 Subject: [PATCH] chore(docs): tweak nexus module intro --- website/content/040-api/01-nexus/index.mdx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/website/content/040-api/01-nexus/index.mdx b/website/content/040-api/01-nexus/index.mdx index a54733b08..365ad0ff1 100644 --- a/website/content/040-api/01-nexus/index.mdx +++ b/website/content/040-api/01-nexus/index.mdx @@ -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: { @@ -29,7 +29,7 @@ app.settings.change({ app.schema.queryType({ definition(t) { - t.field('foo', { type: 'String' }) + t.string('foo', () => 'bar') }, }) ``` @@ -37,9 +37,11 @@ app.schema.queryType({ ### 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: { @@ -49,7 +51,7 @@ settings.change({ schema.queryType({ definition(t) { - t.field('foo', { type: 'String' }) + t.string('foo', () => 'bar') }, }) ```