Skip to content

Commit 8149340

Browse files
petrus-jvrensburgsmkhalsa
authored andcommitted
docs: a few more tweaks
1 parent c6e4341 commit 8149340

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

docs/custom-scalars.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ gql_build|schema_builder:
3737
type_overrides:
3838
Date:
3939
name: DateTime
40-
import: 'package:my_date_library/date_time.dart'
40+
import: "package:my_date_library/date_time.dart"
4141
```
4242

4343
### Configure Custom Serializer
4444

45-
If our Dart type is not a Dart Data Type, we also need to [define a custom serializer](#create-a-custom-serializer) so that the generated classes can be correctly serialized & deserialized the data.
45+
If our Dart type is not a Dart Data Type, we also need to [define a custom serializer](#create-a-custom-serializer) so that the generated classes can correctly serialize & deserialize the data.
4646

47-
Assuming we've created a [`DateSerializer`](#create-a-custom-serializer) for our custom `Date` scalar, we will need to include it in our `serializer_builder`.
47+
Assuming we've created a [`DateSerializer`](#create-a-custom-serializer) for our custom `Date` scalar, we will need to include it in our `serializer_builder`:
4848

4949
```yaml
5050
gql_build|serializer_builder:
5151
enabled: true
5252
options:
5353
schema: my_project|lib/graphql/schema.graphql
5454
custom_serializers:
55-
- import: 'package:path/to/date_serializer.dart'
55+
- import: "package:path/to/date_serializer.dart"
5656
name: DateSerializer
5757
```
5858

@@ -92,7 +92,7 @@ targets:
9292
options:
9393
schema: my_project|lib/schema.graphql
9494
custom_serializers:
95-
- import: 'package:path/to/date_serializer.dart'
95+
- import: "package:path/to/date_serializer.dart"
9696
name: DateSerializer
9797
9898
ferry_generator|req_builder:
@@ -104,11 +104,11 @@ targets:
104104
name: DateTime
105105
```
106106

107-
## Create a Custom Serializer
107+
## Creating a Custom Serializer
108108

109-
In order for us to instantiate our generated Dart Classes with data from our GraphQL server, we will need to create a custom `built_value` serializer for our custom `scalar` type.
109+
For Ferry to create instances of our generated Dart classes, with data from a GraphQL server, we'll need to create a custom `built_value` serializer to handle the custom `scalar` type.
110110

111-
In this case, let's assume that our GraphQL server will return our `Date` scalar as an `int` timestamp.
111+
Let's assume that our GraphQL server returns our `Date` scalar as an `int` timestamp. Then, a custom serializer can look like this:
112112

113113
```dart
114114
import 'package:built_value/serializer.dart';
@@ -141,13 +141,13 @@ class DateSerializer implements PrimitiveSerializer<DateTime> {
141141
}
142142
```
143143

144-
And that's it! Now when we run our `pub run build_runner build` command, ferry's generators will automatically override our GraphQL `Date` scalar with the Dart `DateTime` type and use our `DateSerializer` to serialize & deserialize data.
144+
And that's it! Now when we run our `pub run build_runner build` command, Ferry's generators will automatically override our GraphQL `Date` scalar with the Dart `DateTime` type and use our `DateSerializer` to serialize & deserialize data.
145145

146146
### Using `StructuredSerializer`s
147147

148148
We've implemented the above `DateSerializer` using the `PrimitiveSerializer` from `built_value`. However, if we were building a serializer for a non-primitive Dart type, we'd probably want to use the `StructuredSerializer` instead.
149149

150-
Since `built_value` doesn't use standard Json by default, rather than implementing `StructuredSerializer` directly, we may prefer to extend the `JsonSerializer` from `gql_code_builder`. For example, here's a serializer for the `Operation` type from `gql_exec` that ferry's generaters use internally.
150+
Since `built_value` doesn't use standard Json by default, rather than implementing `StructuredSerializer` directly, we may prefer to extend the `JsonSerializer` from `gql_code_builder`. For example, here's a serializer for the `Operation` type from `gql_exec` that Ferry's generators use internally.
151151

152152
```dart
153153
import "package:built_value/serializer.dart";

docs/customization.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CacheTypedLink extends TypedLink {
4141

4242
Not all links need to resolve the request directly. Some links simply modify the request or response stream by calling the `forward()` callback on the `request()` method. This defers resolution of the request to the next link in the chain.
4343

44-
For example, ferry uses the following link to automatically add "___typename_" fields to each node of the GraphQL operation.
44+
For example, ferry uses the following link to automatically add "_\_\_typename_" fields to each node of the GraphQL operation.
4545

4646
```dart
4747
import 'dart:async';
@@ -81,7 +81,7 @@ class AddTypenameTypedLink extends TypedLink {
8181

8282
TypedLinks can be chained together using the `TypedLink.from()` method.
8383

84-
The following will create a link that adds "___typename_" fields to the request, then resolves the request from the Cache:
84+
The following will create a link that adds "_\_\_typename_" fields to the request, then resolves the request from the Cache:
8585

8686
```dart
8787
final myTypedLink = TypedLink.from([
@@ -96,8 +96,6 @@ You can then use this link to execute requests by listening to the Stream return
9696
myTypedLink.request(GMyQueryReq()).listen((data) => print(data));
9797
```
9898

99-
100-
10199
### Ordering Your TypedLink Chains
102100

103101
There are a few important guidelines that you should follow when chaining TypedLinks to ensure that your requests get executed correctly.
@@ -120,7 +118,7 @@ Instead, you can simply use the [underlying links that Client composes](https://
120118
The ferry Client is created by composing these core TypedLinks.
121119

122120
- **Client**: The Ferry Client itself is a TypedLink, implemented by composing other core TypedLinks.
123-
- **AddTypenameTypedLink**: Adds "___typename_" to each node of the operation.
121+
- **AddTypenameTypedLink**: Adds "_\_\_typename_" to each node of the operation.
124122
- **CacheTypedLink**: A terminating link that fetches the operation from the Cache.
125123
- **FetchPolicyTypedLink**: A terminating link that resolves an operation from the Link or the Cache based on the request's `FetchPolicy`, possibly caching the response.
126124
- **GqlTypedLink**: A terminating link which defers execution to the provided [gql_link](https://pub.dev/packages/gql_link). Any errors received by the [gql_link](https://pub.dev/packages/gql_link) are included in the `OperationResponse.linkException`.

docs/fetch-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A request's `FetchPolicy` determines how it is resolved by Ferry, either from th
88
For example, executing the following `reviewsReq` will bypass the cache and return results only from the network.
99

1010
```dart
11-
final reviewsReq = GAllPokemonReq(
11+
final reviewsReq = GReviewsReq(
1212
(b) => b
1313
..fetchPolicy = FetchPolicy.NetworkOnly
1414
..vars.first = 10

docs/structuring-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ A naive implementation of this (don't do this) might be to:
120120

121121
However, this would result in a seperate network request (and subsequent database query) for each Pokemon in the list. Not very efficient.
122122

123-
Istead, we can extract our `PokemonCard`'s data requirements into a Fragment:
123+
Instead, we can extract our `PokemonCard`'s data requirements into a Fragment:
124124

125125
```graphql
126126
fragment PokemonCardFragment on Pokemon {

0 commit comments

Comments
 (0)