mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Minor documentation updates
This commit is contained in:
parent
364a5e84a3
commit
0368a98888
@ -952,7 +952,7 @@ We use `Injector.query.register` to register our `readNotes` query as extensible
|
||||
|
||||
#### Applying the injected query as a transformation
|
||||
|
||||
The only missing piece now is to attach the `ReadNotes` injected query to the `NotesList` component. We could have done this using `injectGraphql` in the component itself, but instead, we'll do it as an Injector transformation. Why? There's a good chance whoever is customising the query will want to customise the UI of the component that is using that query. If someone adds a new field, it is likely the component should display that new field. Registering the GraphQL injection as a transformation will allow a thirdparty developer to override the UI of the component explicitly *after* the GraphQL query is attached. This is important, because otherwise, the component override would not be wired up to your data source.
|
||||
The only missing piece now is to attach the `ReadNotes` injected query to the `NotesList` component. We could have done this using `injectGraphql` in the `NotesList` component itself, but instead, we'll do it as an Injector transformation. Why? There's a good chance whoever is customising the query will want to customise the UI of the component that is using that query. If someone adds a new field to a query, it is likely the component should display that new field. Registering the GraphQL injection as a transformation will allow a thirdparty developer to override the UI of the component explicitly *after* the GraphQL query is attached. This is important, because otherwise, the component override would not be wired up to your data source.
|
||||
|
||||
*myapp/client/registerDependencies.js*
|
||||
```js
|
||||
@ -1000,7 +1000,7 @@ You can register this with `Injector`, too, but since it's already injected with
|
||||
|
||||
#### Bootstrap and mount
|
||||
|
||||
Since almost everything is in `Injector` now, our app definition is pretty trivial.
|
||||
Since almost everything is in `Injector` now, our mounting code is pretty trivial.
|
||||
|
||||
*myapp/client/index.js*
|
||||
```js
|
||||
@ -1049,6 +1049,7 @@ We'll first need to apply the extension and update our GraphQL scaffolding.
|
||||
```yaml
|
||||
MyApp\AwesomeNotes\Note:
|
||||
extensions:
|
||||
# this extension adds a "Priority" field
|
||||
- MyOtherApp\NastyNotes\NoteExtension
|
||||
SilverStripe\GraphQL\Controller:
|
||||
schema:
|
||||
@ -1109,7 +1110,7 @@ Injector.transform(
|
||||
|
||||
Let's now add an `AddForm` component to our list that lets the user create a new note.
|
||||
|
||||
*myapp/client/App.js
|
||||
*myapp/client/App.js*
|
||||
```js
|
||||
import React from 'react';
|
||||
import { inject } from 'lib/Injector';
|
||||
@ -1170,7 +1171,7 @@ const mutation = {
|
||||
mutate({
|
||||
variables: {
|
||||
Input: {
|
||||
Content: title,
|
||||
Content: content,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user