Integrate codespell for Book (#1121)
- add `codespell` CI job - add `book.codespell` Makefile command - fix Book typos found by codespell Co-authored-by: Kai Ren <tyranron@gmail.com>
This commit is contained in:
parent
d11e351a49
commit
0fc95ddbff
8 changed files with 35 additions and 10 deletions
2
.codespellrc
Normal file
2
.codespellrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[codespell]
|
||||||
|
ignore-words-list = crate
|
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
|
@ -24,6 +24,7 @@ jobs:
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
needs:
|
needs:
|
||||||
- bench
|
- bench
|
||||||
|
- codespell
|
||||||
- clippy
|
- clippy
|
||||||
- feature
|
- feature
|
||||||
- msrv
|
- msrv
|
||||||
|
@ -54,6 +55,15 @@ jobs:
|
||||||
|
|
||||||
- run: make cargo.lint
|
- run: make cargo.lint
|
||||||
|
|
||||||
|
codespell:
|
||||||
|
name: codespell (Book)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: codespell-project/actions-codespell@v2
|
||||||
|
with:
|
||||||
|
path: book/
|
||||||
|
|
||||||
rustfmt:
|
rustfmt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -342,6 +352,7 @@ jobs:
|
||||||
needs:
|
needs:
|
||||||
- bench
|
- bench
|
||||||
- clippy
|
- clippy
|
||||||
|
- codespell
|
||||||
- feature
|
- feature
|
||||||
- msrv
|
- msrv
|
||||||
- package
|
- package
|
||||||
|
@ -391,7 +402,7 @@ jobs:
|
||||||
name: deploy (Book)
|
name: deploy (Book)
|
||||||
if: ${{ github.ref == 'refs/heads/master'
|
if: ${{ github.ref == 'refs/heads/master'
|
||||||
|| startsWith(github.ref, 'refs/tags/juniper@') }}
|
|| startsWith(github.ref, 'refs/tags/juniper@') }}
|
||||||
needs: ["test", "test-book"]
|
needs: ["codespell", "test", "test-book"]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
16
Makefile
16
Makefile
|
@ -18,6 +18,9 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
|
||||||
book: book.build
|
book: book.build
|
||||||
|
|
||||||
|
|
||||||
|
codespell: book.codespell
|
||||||
|
|
||||||
|
|
||||||
fmt: cargo.fmt
|
fmt: cargo.fmt
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,6 +140,15 @@ book.build:
|
||||||
mdbook build book/ $(if $(call eq,$(out),),,-d $(out))
|
mdbook build book/ $(if $(call eq,$(out),),,-d $(out))
|
||||||
|
|
||||||
|
|
||||||
|
# Spellcheck Book.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# make book.codespell [fix=(no|yes)]
|
||||||
|
|
||||||
|
book.codespell:
|
||||||
|
codespell book/ $(if $(call eq,$(fix),yes),--write-changes,)
|
||||||
|
|
||||||
|
|
||||||
# Serve Book on some port.
|
# Serve Book on some port.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
|
@ -180,8 +192,8 @@ graphql-playground:
|
||||||
# .PHONY section #
|
# .PHONY section #
|
||||||
##################
|
##################
|
||||||
|
|
||||||
.PHONY: book fmt lint release test \
|
.PHONY: book codespell fmt lint release test \
|
||||||
book.build book.serve \
|
book.build book.codespell book.serve \
|
||||||
cargo.fmt cargo.lint cargo.release cargo.test \
|
cargo.fmt cargo.lint cargo.release cargo.test \
|
||||||
graphiql graphql-playground \
|
graphiql graphql-playground \
|
||||||
test.book test.cargo
|
test.book test.cargo
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Avoiding the N+1 Problem With Dataloaders
|
# Avoiding the N+1 Problem With Dataloaders
|
||||||
|
|
||||||
A common issue with graphql servers is how the resolvers query their datasource.
|
A common issue with graphql servers is how the resolvers query their datasource.
|
||||||
This issue results in a large number of unneccessary database queries or http requests.
|
This issue results in a large number of unnecessary database queries or http requests.
|
||||||
Say you were wanting to list a bunch of cults people were in
|
Say you were wanting to list a bunch of cults people were in
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Multiple operations per request
|
# Multiple operations per request
|
||||||
|
|
||||||
The GraphQL standard generally assumes there will be one server request for each client operation you want to perform (such as a query or mutation). This is conceptually simple but has the potential to be inefficent.
|
The GraphQL standard generally assumes there will be one server request for each client operation you want to perform (such as a query or mutation). This is conceptually simple but has the potential to be inefficient.
|
||||||
|
|
||||||
Some client libraries such as [apollo-link-batch-http](https://www.apollographql.com/docs/link/links/batch-http.html) have added the ability to batch operations in a single HTTP request to save network round-trips and potentially increase performance. There are some [tradeoffs](https://blog.apollographql.com/batching-client-graphql-queries-a685f5bcd41b) that should be considered before batching requests.
|
Some client libraries such as [apollo-link-batch-http](https://www.apollographql.com/docs/link/links/batch-http.html) have added the ability to batch operations in a single HTTP request to save network round-trips and potentially increase performance. There are some [tradeoffs](https://blog.apollographql.com/batching-client-graphql-queries-a685f5bcd41b) that should be considered before batching requests.
|
||||||
|
|
||||||
|
|
|
@ -61,13 +61,13 @@ Also, enum name can be specified explicitly, if desired.
|
||||||
# extern crate juniper;
|
# extern crate juniper;
|
||||||
use juniper::{graphql_interface, GraphQLObject};
|
use juniper::{graphql_interface, GraphQLObject};
|
||||||
|
|
||||||
#[graphql_interface(enum = CharaterInterface, for = Human)]
|
#[graphql_interface(enum = CharacterInterface, for = Human)]
|
||||||
trait Character {
|
trait Character {
|
||||||
fn id(&self) -> &str;
|
fn id(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GraphQLObject)]
|
#[derive(GraphQLObject)]
|
||||||
#[graphql(impl = CharaterInterface)]
|
#[graphql(impl = CharacterInterface)]
|
||||||
struct Human {
|
struct Human {
|
||||||
id: String,
|
id: String,
|
||||||
home_planet: String,
|
home_planet: String,
|
||||||
|
@ -248,7 +248,7 @@ use juniper::{graphql_interface, GraphQLObject};
|
||||||
pub struct ObjA {
|
pub struct ObjA {
|
||||||
id: Vec<String>,
|
id: Vec<String>,
|
||||||
// ^^ the evaluated program panicked at
|
// ^^ the evaluated program panicked at
|
||||||
// 'Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of
|
// 'Failed to implement interface `Character` on `ObjA`: Field `id`: implementer is expected to return a subtype of
|
||||||
// interface's return object: `[String!]!` is not a subtype of `String!`.'
|
// interface's return object: `[String!]!` is not a subtype of `String!`.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl User {
|
||||||
let DatabaseContext(context) = context;
|
let DatabaseContext(context) = context;
|
||||||
// If context is immutable use .read() on RwLock.
|
// If context is immutable use .read() on RwLock.
|
||||||
let mut context = context.write().await;
|
let mut context = context.write().await;
|
||||||
// Preform a mutable operation.
|
// Perform a mutable operation.
|
||||||
context.requested_count.entry(self.id).and_modify(|e| { *e += 1 }).or_insert(1).clone()
|
context.requested_count.entry(self.id).and_modify(|e| { *e += 1 }).or_insert(1).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Other Types
|
# Other Types
|
||||||
|
|
||||||
The GraphQL type system provides several types in additon to objects.
|
The GraphQL type system provides several types in addition to objects.
|
||||||
|
|
||||||
Find out more about each type below:
|
Find out more about each type below:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue