Skip to content

Commit

Permalink
Merge branch 'main' into ds-copy-fix-from-learn-pr-207
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar authored Mar 18, 2022
2 parents 06f18a3 + 16971af commit efc586f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
20 changes: 10 additions & 10 deletions docs/docs/cells.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ Off the bat, this file exports five constants: `QUERY`, `Loading` , `Empty` , `F

With Cells, you have a total of seven exports to work with:

| Name | Type | Description |
| :------------ | :---------------- | :----------------------------------------------------------- |
| `QUERY` | `string|function` | The query to execute |
| `beforeQuery` | `function` | Lifecycle hook; prepares variables and options for the query |
| `isEmpty` | `function` | Lifecycle hook; decides if Cell should render Empty |
| `afterQuery` | `function` | Lifecycle hook; sanitizes data returned from the query |
| `Loading` | `component` | If the request is in flight, render this component |
| `Empty` | `component` | If there's no data (`null` or `[]`), render this component |
| `Failure` | `component` | If something went wrong, render this component |
| `Success` | `component` | If the data has loaded, render this component |
| Name | Type | Description |
| :------------ | :----------------- | :----------------------------------------------------------- |
| `QUERY` | `string\|function` | The query to execute |
| `beforeQuery` | `function` | Lifecycle hook; prepares variables and options for the query |
| `isEmpty` | `function` | Lifecycle hook; decides if Cell should render Empty |
| `afterQuery` | `function` | Lifecycle hook; sanitizes data returned from the query |
| `Loading` | `component` | If the request is in flight, render this component |
| `Empty` | `component` | If there's no data (`null` or `[]`), render this component |
| `Failure` | `component` | If something went wrong, render this component |
| `Success` | `component` | If the data has loaded, render this component |

Only `QUERY` and `Success` are required. If you don't export `Empty`, empty results are sent to `Success`, and if you don't export `Failure`, error is output to the console.

Expand Down
19 changes: 19 additions & 0 deletions docs/docs/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,25 @@ And then check `web/generators/page` for the page, storybook and test template f

The only exception to this rule is the scaffold templates. You'll get four directories, `assets`, `components`, `layouts` and `pages`. If you want to customize any one of the templates in those directories, you will need to keep all the other files inside of that same directory, even if you make no changes besides the one you care about. (This is due to the way the scaffold looks up its template files.) For example, if you wanted to customize only the index page of the scaffold (the one that lists all available records in the database) you would edit `web/generators/scaffold/pages/NamesPage.tsx.template` and keep the other pages in that directory. You _could_ delete the other three directories (`assets`, `components`, `layouts`) if you don't need to customize them.

**Name Variants**

Your template will receive the provided `name` in a number of different variations.

For example, given the name `fooBar` your template will receive the following _variables_ with the given _values_

| Variable | Value |
| :------------------------ | :------------ |
| `pascalName` | `FooBar` |
| `camelName` | `fooBar` |
| `singularPascalName` | `FooBar` |
| `pluralPascalName` | `FooBars` |
| `singularCamelName` | `fooBar` |
| `pluralCamelName` | `fooBars` |
| `singularParamName` | `foo-bar` |
| `pluralParamName` | `foo-bars` |
| `singularConstantName` | `FOO_BAR` |
| `pluralConstantName` | `FOO_BARS` |

**Example**

Copying the cell generator templates:
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ const SomePage = () => {
}
```

In addition to the `to` prop, `<Redirect />` also takes an `options` prop. This is the same as [`navigate()`](https://redwoodjs.com/docs/router#navigate)'s second argument: `navigate(_, { replace: true })`. We can use it to *replace* the top item of the browser history stack (instead of pushing a new one). This is how you use it to have this effect: `<Redirect to={routes.home()} options={{ replace: true }}/>`.

## Code-splitting

By default, the router will code-split on every Page, creating a separate lazy-loaded webpack bundle for each. When navigating from page to page, the router will wait until the new Page module is loaded before re-rendering, thus preventing the "white-flash" effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Redwood likes GraphQL. We think it's the API of the future. Our GraphQL implemen

![Redwood Data Flow](https://user-images.githubusercontent.com/300/75402679-50bdd180-58ba-11ea-92c9-bb5a5f4da659.png)

The front-end uses [Apollo Client](https://www.apollographql.com/docs/react/) to create a GraphQL payload sent to [GraphQL Helix](https://graphql-helix.vercel.app/) and [Envelop](https://www.envelop.dev/docs), which that `graphql.js` file acts as the entry-point to.
The front-end uses [Apollo Client](https://www.apollographql.com/docs/react/) to create a GraphQL payload sent to [GraphQL Helix](https://graphql-helix.vercel.app/) and [Envelop](https://www.envelop.dev/docs), for which that `graphql.js` file acts as the entry-point to.

The `*.sdl.js` files in `api/src/graphql` define the GraphQL [Object](https://www.apollographql.com/docs/tutorial/schema/#object-types), [Query](https://www.apollographql.com/docs/tutorial/schema/#the-query-type) and [Mutation](https://www.apollographql.com/docs/tutorial/schema/#the-mutation-type) types and thus the interface of your API.

Expand Down

0 comments on commit efc586f

Please sign in to comment.