Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #1464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ If you are having issues with `sharp` dependency, please make sure you have inst

To check the version you have, run: `yarn why sharp`.

If you are still having issues, please make sure that you have `SHARP_DIST_BASE_URL` environemnt variable set correctly (see `.env` file) and then run `yarn install` again.
If you are still having issues, please make sure that you have `SHARP_DIST_BASE_URL` environment variable set correctly (see `.env` file) and then run `yarn install` again.

2 changes: 1 addition & 1 deletion content/backend/graphql-go/2-queries.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Queries
pageTitle: 'Building a GraphQL Server with Go Backend Tutorial | Quiries'
pageTitle: 'Building a GraphQL Server with Go Backend Tutorial | Queries'
description: 'what are queries and implementing a query in gqlgen'
---

Expand Down
17 changes: 8 additions & 9 deletions content/backend/graphql-java/11-alternative-approaches.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ and then you created a corresponding POJO:

```java(nocopy)
public class Link {

private final String id;
private final String url;
private final String description;

//constructors, getters and setters
//...
}
```

Both of these blocks contain the exact same information. Worse yet, changing one requires immediate change to the other. This makes refactoring risky and cumbersome. On the other hand, if you're trying to introduce a GraphQL API into an existing project, writing the schema practically means re-describing the entire existing model. This is both expensive and error-prone, and still suffers from duplication.
Both of these blocks contain the exact same information. Worse yet, changing one requires immediate change to the other. This makes refactoring risky and cumbersome. On the other hand, if you're trying to introduce a GraphQL API into an existing project, writing the schema practically means re-describing the entire existing model. This is both expensive and error-prone, and still suffers from duplication.

### Code-first style

Expand Down Expand Up @@ -61,7 +61,7 @@ Additionally, it will be much more comfortable to work if the [method parameter

<Instruction>

So enable the `-paramaters` javac option by configuring the `maven-compiler-plugin` as follows:
So enable the `-parameters` javac option by configuring the `maven-compiler-plugin` as follows:

```xml(path=".../hackernews-graphql-java/pom.xml")
<plugin>
Expand Down Expand Up @@ -121,7 +121,7 @@ Decorate the interesting bits in `LinkResolver` too:

```java(path=".../hackernews-graphql-java/src/main/java/com/howtographql/hackernews/LinkResolver.java")
public class LinkResolver { //1

private final UserRepository userRepository;

LinkResolver(UserRepository userRepository) {
Expand Down Expand Up @@ -167,14 +167,14 @@ Things to note:

<Instruction>

Finally, to generate the schema from the classes, update `GraphQLEndoint#buildSchema` to look as follows:
Finally, to generate the schema from the classes, update `GraphQLEndpoint#buildSchema` to look as follows:

```java(path=".../hackernews-graphql-java/src/main/java/com/howtographql/hackernews/GraphQLEndoint.java")
private static GraphQLSchema buildSchema() {
Query query = new Query(linkRepository); //create or inject the service beans
LinkResolver linkResolver = new LinkResolver(userRepository);
Mutation mutation = new Mutation(linkRepository, userRepository, voteRepository);

return new GraphQLSchemaGenerator()
.withOperationsFromSingletons(query, linkResolver, mutation) //register the beans
.generate(); //done :)
Expand All @@ -191,7 +191,6 @@ If you now fire up GraphiQL, you'd get the exact same result as before:
The important points to note:

* You never defined the schema explicitly (meaning you won't have to update it when the code changes either).
* You don't have to separate the logic for manipulating `Link`s into the top level queries (`allLinks` inside `Query`), embedded ones (`postedBy` inside `LinkResolver`) and mutations (`createLink` inside `Mutation`). All the queries and mutations operating on links could have been placed into a single class (e.g. `LinkService`), yet having them separate was not a hurdle either. This implies that your legacy code and best practices can stay untouched.
* You don't have to separate the logic for manipulating `Link`s into the top level queries (`allLinks` inside `Query`), embedded ones (`postedBy` inside `LinkResolver`) and mutations (`createLink` inside `Mutation`). All the queries and mutations operating on links could have been placed into a single class (e.g. `LinkService`), yet having them separate was not a hurdle either. This implies that your legacy code and best practices can stay untouched.

This is just a glance at the alternative style of development. There are many more possibilities to explore, so take a look at what [the ecosystem](https://github.com/graphql-java/awesome-graphql-java) has to offer. For more info on `graphql-spqr` check out [the project page](https://github.com/leangen/graphql-spqr), and for a full example see [here](https://github.com/leangen/graphql-spqr-samples).

2 changes: 1 addition & 1 deletion content/backend/graphql-java/6-more-mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ This one will require quite a few steps, so buckle up!

</Instruction>

4. This is an interesting step. You need to create a new scalar type to represent an instant in time. For this, you need an instance of `GraphQLScalarType`. For reference on how to create these, you can check out the build-in types in [`graphql-java`](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/Scalars.java#L34).
4. This is an interesting step. You need to create a new scalar type to represent an instant in time. For this, you need an instance of `GraphQLScalarType`. For reference on how to create these, you can check out the built-in types in [`graphql-java`](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/Scalars.java#L34).

<Instruction>

Expand Down
44 changes: 22 additions & 22 deletions content/backend/graphql-java/9-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,77 @@ You'll now apply this idea to add filtering to the already defined `allLinks` qu
1. Start by add a new argument to its schema definition

<Instruction>

Introduce the `LinkFilter` argument to `allLinks`

```graphql(path=".../hackernews-graphql-java/src/main/resources/schema.graphqls")
type Query {
allLinks(filter: LinkFilter): [Link]
}

input LinkFilter {
description_contains: String
url_contains: String
}
```

</Instruction>

Remember that this exact approach is just an example. You might as well implement filtering using any other format.

2. Create the corresponding data-class

<Instruction>

The `LinkFilter` POJO should look something like the following:

```java(path=".../hackernews-graphql-java/src/main/java/com/howtographql/hackernews/LinkFilter.java")
import com.fasterxml.jackson.annotation.JsonProperty;

public class LinkFilter {

private String descriptionContains;
private String urlContains;

@JsonProperty("description_contains") //the name must match the schema
public String getDescriptionContains() {
return descriptionContains;
}

public void setDescriptionContains(String descriptionContains) {
this.descriptionContains = descriptionContains;
}

@JsonProperty("url_contains")
public String getUrlContains() {
return urlContains;
}

public void setUrlContains(String urlContains) {
this.urlContains = urlContains;
}
}
```

</Instruction>

3. The logic needs to allow filtering

<Instruction>
Update `LinkRespository#getAllLinks` to accept an optional filter:

Update `LinkRepository#getAllLinks` to accept an optional filter:

```java(path=".../hackernews-graphql-java/src/main/java/com/howtographql/hackernews/LinkRepository.java")
public List<Link> getAllLinks(LinkFilter filter) {
Optional<Bson> mongoFilter = Optional.ofNullable(filter).map(this::buildFilter);

List<Link> allLinks = new ArrayList<>();
for (Document doc : mongoFilter.map(links::find).orElseGet(links::find)) {
allLinks.add(link(doc));
}
return allLinks;
}

//builds a Bson from a LinkFilter
private Bson buildFilter(LinkFilter filter) {
String descriptionPattern = filter.getDescriptionContains();
Expand All @@ -105,21 +105,21 @@ Remember that this exact approach is just an example. You might as well implemen
return descriptionCondition != null ? descriptionCondition : urlCondition;
}
```

</Instruction>

4. Finally, update `Query` to add the new argument to the top-level method:

<Instruction>

Add the `filter` parameter to `Query#allLinks`:

```java(path=".../hackernews-graphql-java/src/main/java/com/howtographql/hackernews/Query.java")
public List<Link> allLinks(LinkFilter filter) {
return linkRepository.getAllLinks(filter);
}
```

</Instruction>

Cool! Check it out in GraphiQL!
Expand Down
2 changes: 1 addition & 1 deletion content/backend/graphql-js/6-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module.exports = {

</Instruction>

This is pretty straighforward. You're just reimplementing the same functionality from before with a dedicated function in a different file. The `Mutation` resolvers are next.
This is pretty straightforward. You're just reimplementing the same functionality from before with a dedicated function in a different file. The `Mutation` resolvers are next.

#### Adding authentication resolvers

Expand Down
2 changes: 1 addition & 1 deletion content/backend/graphql-scala/2-preparing-first-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ sbt run
</Instruction>

And open in the browser an url [http://localhost:8080/graphiql](http://localhost:8080/graphiql)
Of couse use different port number if you haven't decided to default one during project initialization.
Of course use different port number if you haven't decided to default one during project initialization.
<Instruction>

In graphiql console execute the following code:
Expand Down
6 changes: 3 additions & 3 deletions content/backend/graphql-scala/5-custom-scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Add column mapper for our `DateTime` type in `DBSchema` object (before the `Link
import java.sql.Timestamp


//and at the begining of the class' body:
//and at the beginning of the class' body:
implicit val dateTimeColumnType = MappedColumnType.base[DateTime, Timestamp](
dt => new Timestamp(dt.clicks),
ts => DateTime(ts.getTime)
Expand Down Expand Up @@ -132,7 +132,7 @@ object DBSchema {
val Links = TableQuery[LinksTable]

/**
* Load schema and populate sample data withing this Sequence od DBActions
* Load schema and populate sample data within this Sequence od DBActions
*/
val databaseSetup = DBIO.seq(
Links.schema.create,
Expand Down Expand Up @@ -181,7 +181,7 @@ In `GraphQLSchema` add the following code:
//imports:
import sangria.ast.StringValue

//begining of the object's body:
//beginning of the object's body:
implicit val GraphQLDateTime = ScalarType[DateTime](//1
"DateTime",//2
coerceOutput = (dt, _) => dt.toString, //3
Expand Down
18 changes: 9 additions & 9 deletions content/backend/graphql-scala/6-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ correctAnswer: 3

Before you go further, try to implement the changes yourself. I think, at this point, you have the necessary knowledge to add the `User` and `Vote` models. I'll show what to do later in this chapter, but try to implement it yourself first.

What you have to do:
What you have to do:

1. Add `User` class with fields: `id`, `name`, `email`, `password` and `createdAt`
1. Add `Vote` class with fields: `id`, `createdAt`, `userId`, `linkId`(you don't have to to define any relations for now)
Expand Down Expand Up @@ -68,7 +68,7 @@ Sample entities:

In DBSchema in the function `databaseSetup`, add an action `Users.schema.create` at beginning of the function and then add a few users later in this function:

```scala
```scala
Users forceInsertAll Seq(
User(1, "mario", "mario@example.com", "s3cr3t"),
User(2, "Fred", "fred@flinstones.com", "wilmalove")
Expand All @@ -93,7 +93,7 @@ def getUsers(ids: Seq[Int]): Future[Seq[User]] = {

</Instruction>

Dont' forget about `import com.howtographql.scala.sangria.models.User`...
Don't forget about `import com.howtographql.scala.sangria.models.User`...

GraphQL part:

Expand Down Expand Up @@ -278,7 +278,7 @@ query {
id
createdAt
}
}
}
```

### Finding common parts
Expand Down Expand Up @@ -350,7 +350,7 @@ val IdentifiableType = InterfaceType(
Field("id", IntType, resolve = _.value.id)
)
)

implicit val LinkType = deriveObjectType[Unit, Link](
Interfaces(IdentifiableType)
)
Expand All @@ -364,10 +364,10 @@ Now if you look into the schema definition in graphiql console you will see that

So far so good. We made many changes in this chapter, so if you like you can compare current state o files with the following snippets.

[GraphQLSchema.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-graphqlschema-scala)
[models/package.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-models_package-scala)
[DAO.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-dao-scala)
[DBSchema.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-dbschema-scala)
[GraphQLSchema.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-graphqlschema-scala)
[models/package.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-models_package-scala)
[DAO.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-dao-scala)
[DBSchema.scala](https://gist.github.com/marioosh/6f75f24bb5e5fd6fc3d46472147c4551#file-dbschema-scala)


---
Expand Down
2 changes: 1 addition & 1 deletion content/backend/graphql-scala/7-relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ We achieved our goal for this chapter, our models have new functions:

Now we can fetch the related data...

The current state of fileds we've changed in this chapter you can compare with those gists:
The current state of fields we've changed in this chapter you can compare with those gists:

[DAO.scala](https://gist.github.com/marioosh/7c3ee5fed1238c5daf89a4459727f575#file-dao-scala)
[models/package.scala](https://gist.github.com/marioosh/7c3ee5fed1238c5daf89a4459727f575#file-models_package-scala)
Expand Down
4 changes: 2 additions & 2 deletions content/backend/graphql-scala/8-mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ lazy val AuthProviderSignupDataInputType: InputObjectType[AuthProviderSignupData

</Instruction>

To avoid circular dependencies of types, like we've experiences in the last chapter ther a suggestion to use `lazy` keyword for every type.
But in case above, `AuthProviderEmail` is nested object in `AuthProviderSignupData` which is built by macro. Thats why we had to add `implicit`
To avoid circular dependencies of types, like we've experiences in the last chapter their a suggestion to use `lazy` keyword for every type.
But in case above, `AuthProviderEmail` is nested object in `AuthProviderSignupData` which is built by macro. That's why we had to add `implicit`
we have to have this nested object type in the scope in the time of macro executing.


Expand Down
2 changes: 1 addition & 1 deletion content/backend/graphql-scala/9-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ mutation loginAndAddLink {
}
```

You can experiment with the query above, check the reponse when you provide wrong email or password, or what will happen when you'll skip
You can experiment with the query above, check the response when you provide wrong email or password, or what will happen when you'll skip
entire `login` mutation.


Expand Down
2 changes: 1 addition & 1 deletion content/backend/typescript-apollo/3-a-simple-mutation.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ type Mutation {
}
```

The [Nexus documentation](https://nexusjs.org/docs/) might come in handy when attempting this excercise.
The [Nexus documentation](https://nexusjs.org/docs/) might come in handy when attempting this exercise.
Loading