Skip to content
Merged
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
20 changes: 11 additions & 9 deletions src/content/docs/graphql/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ You need the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0). [
dotnet run --project ./src/Presentation
```

5. Open Nitro, the GraphQL IDE, at [http://localhost:5032/graphql](http://localhost:5032/graphql). The schema is on the left, with every type and field described, and the editor autocompletes as you type. Paste this in and press play:
It answers on `https://localhost:8081`. If your browser or `curl` doesn't trust the .NET development certificate yet, run `dotnet dev-certs https --trust` once.

5. Open Nitro, the GraphQL IDE, at [https://localhost:8081/graphql](https://localhost:8081/graphql). The schema is on the left, with every type and field described, and the editor autocompletes as you type. Paste this in and press play:

```graphql
{
movies(query: "global", first: 2) {
movies(query: "space", first: 2) {
totalCount
pageInfo { hasNextPage endCursor }
nodes { id title reviewCount averageStars }
Expand All @@ -72,8 +74,8 @@ You need the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0). [
6. Or ask from the terminal.

```bash
curl -X POST "http://localhost:5032/graphql" -H "Content-Type: application/json" \
-d '{"query":"{ movies(query: \"global\", first: 2) { totalCount nodes { id title reviewCount averageStars } } }"}'
curl -X POST "https://localhost:8081/graphql" -H "Content-Type: application/json" \
-d '{"query":"{ movies(query: \"space\", first: 2) { totalCount nodes { id title reviewCount averageStars } } }"}'
```

Either way you get a page of movies back:
Expand All @@ -82,18 +84,18 @@ You need the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0). [
{
"data": {
"movies": {
"totalCount": 2,
"pageInfo": { "hasNextPage": false, "endCursor": "b2Zmc2V0OjI=" },
"totalCount": 4,
"pageInfo": { "hasNextPage": true, "endCursor": "b2Zmc2V0OjI=" },
"nodes": [
{ "id": "30fca414-247a-779e-105a-d81aa2506f58", "title": "Assimilated global infrastructure", "reviewCount": 1, "averageStars": 1 },
{ "id": "c27d6600-79a6-9346-2595-a52b7f07dc3e", "title": "Automated global alliance", "reviewCount": 3, "averageStars": 3.3 }
{ "id": "cb188ef6-14e7-f85f-2f78-924c2ab26b28", "title": "Deep Space Gardeners", "reviewCount": 5, "averageStars": 3.4 },
{ "id": "dfefa450-5454-6a4d-a4aa-95a9b047c17b", "title": "Postcards from Outer Space", "reviewCount": 1, "averageStars": 3 }
]
}
}
}
```

Yes, the movies are named by a corporate buzzword generator. *Assimilated global infrastructure* only got one star. Critics can be harsh.
The sample movies are all made up. *Deep Space Gardeners* averages 3.4 stars from five reviews, which seems fair for a film about weeding in zero gravity.

7. Run the tests while you're here.

Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/graphql/guides/add-a-field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This guide adds `bestReview` to the `Movie` type: the highest rated review of th

```bash
dotnet run --project ./src/Presentation
curl "http://localhost:5032/graphql?sdl" > tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql
curl "https://localhost:8081/graphql?sdl" > tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql
```

The diff is the one field, described:
Expand Down Expand Up @@ -117,18 +117,18 @@ This guide adds `bestReview` to the `Movie` type: the highest rated review of th

```graphql
{
movie(id: "e159975e-4e6a-1ffd-713e-1eb9d8d4a593") {
movie(id: "cb188ef6-14e7-f85f-2f78-924c2ab26b28") {
title
bestReview { stars author { firstName lastName } }
}
}
```

```json
{ "data": { "movie": { "title": "Assimilated disintermediate adapter", "bestReview": { "stars": 5, "author": { "firstName": "Jana", "lastName": "Auer" } } } } }
{ "data": { "movie": { "title": "Deep Space Gardeners", "bestReview": { "stars": 5, "author": { "firstName": "Caroline", "lastName": "Bins" } } } } }
```

Jana gave it five stars. Jana's average is 2.6, so this is high praise.
Caroline gave it five stars, and three in a second review. Caroline contains multitudes.

</Steps>

Expand Down
12 changes: 6 additions & 6 deletions src/content/docs/graphql/guides/run-locally.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ There are two ready-made environments. `local` is for `dotnet run`: sample data
dotnet run --project ./src/Presentation
```

`launchSettings.json` sets the environment to `local` and listens on [http://localhost:5032](http://localhost:5032) and `https://localhost:7032`.
`launchSettings.json` sets the environment to `local` and listens on [https://localhost:8081](https://localhost:8081), and on `https://localhost:8081`, which redirects to it. If your browser or `curl` doesn't trust the .NET development certificate yet, run `dotnet dev-certs https --trust` once.
</TabItem>
<TabItem label="Docker Compose">
```bash
Expand Down Expand Up @@ -66,18 +66,18 @@ Nitro is the easy way: it knows the schema, autocompletes, and keeps your query
```graphql
# One movie, its reviews and who wrote them
{
movie(id: "e159975e-4e6a-1ffd-713e-1eb9d8d4a593") {
movie(id: "cb188ef6-14e7-f85f-2f78-924c2ab26b28") {
title
reviews { stars author { firstName lastName } }
reviews { stars text author { firstName lastName } }
}
}
```

```graphql
# Write a review
mutation {
createReview(input: { authorId: "01fa8b58-05d2-abd4-e55c-2633222dd0a5", movieId: "e159975e-4e6a-1ffd-713e-1eb9d8d4a593", stars: 5 }) {
review { id stars }
createReview(input: { authorId: "01fa8b58-05d2-abd4-e55c-2633222dd0a5", movieId: "cb188ef6-14e7-f85f-2f78-924c2ab26b28", stars: 5, text: "Great film. I cried at the ending." }) {
review { id stars text }
errors { __typename ... on Error { message } }
}
}
Expand Down Expand Up @@ -117,5 +117,5 @@ docker build . --target run --tag acme-movies:latest \
The `version` query then reports `1.2.3-beta` and the commit it was built from.

<Aside type="tip" title="Stuck?">
If Nitro loads but can't reach the schema, you're probably on `https://` with a certificate your browser doesn't trust yet. Use the `http://` address, or run `dotnet dev-certs https --trust` once. If `curl` says connection refused, check that port 5032 isn't busy with something else you forgot about.
If Nitro loads but can't reach the schema, you're probably on `https://` with a certificate your browser doesn't trust yet. Run `dotnet dev-certs https --trust` once and reload. The `http://` address only redirects to `https://`, so it doesn't help. If `curl` says connection refused, check that ports 8080 and 8081 aren't busy with something else you forgot about.
</Aside>
2 changes: 1 addition & 1 deletion src/content/docs/graphql/guides/secure-the-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Out of the box the API runs wide open, and there's no authentication code in it
2. Get a token from the authority for that audience, and send it.

```bash
curl -X POST "http://localhost:5032/graphql" -H "Authorization: Bearer eyJhbGciOi..." \
curl -X POST "https://localhost:8081/graphql" -H "Authorization: Bearer eyJhbGciOi..." \
-H "Content-Type: application/json" -d '{"query":"{ movies { totalCount } }"}'
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/graphql/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ Every span, metric and log also carries `service.version`, the version stamped i

## Ports when running with dotnet run

`src/Presentation/Properties/launchSettings.json` sets `DOTNET_ENVIRONMENT=local` and listens on `http://localhost:5032` and `https://localhost:7032`.
`src/Presentation/Properties/launchSettings.json` sets `DOTNET_ENVIRONMENT=local` and listens on `http://localhost:8080` and `https://localhost:8081`.
23 changes: 14 additions & 9 deletions src/content/docs/graphql/reference/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar:
order: 1
---

The schema lives in `src/Presentation/GraphQL`: queries in `Queries`, mutations in `Mutations`, object types in `Types` and the errors mutations return in `Errors`. The endpoint is `/graphql`, which also serves Nitro to a browser, and `/graphql?sdl` returns the schema as SDL. Every query and mutation, `version` included, requires authorization, which only has an effect when [authentication is on](../../guides/secure-the-api/).
The schema lives in `src/Presentation/GraphQL`: queries in `Queries`, mutations in `Mutations`, object types in `Types` and the errors mutations return in `Errors`. The endpoint is `/graphql`, which also serves Nitro to a browser, and `/graphql?sdl` returns the schema as SDL. In a solution created with `--include-auth`, every query and mutation, `version` included, needs a token (see [Secure the API](../../guides/secure-the-api/)).

Ids are the `UUID` scalar. Field and type descriptions come from the XML comments on the code, so Nitro shows the same text as this page.

Expand All @@ -18,14 +18,14 @@ Ids are the `UUID` scalar. Field and type descriptions come from the XML comment
| `author` | `id: UUID!` | [`Author`](#author), or null when there's no author with that id |
| `authors` | `query: String`, `first: Int`, `after: String` | A [connection](#connections-and-paging) of [`AuthorSummary`](#authorsummary), ordered by last name then first name |
| `review` | `id: UUID!` | [`Review`](#review), or null when there's no review with that id |
| `reviews` | `movieId: UUID`, `authorId: UUID`, `first: Int`, `after: String` | A [connection](#connections-and-paging) of [`Review`](#review), ordered by movie then author |
| `reviews` | `movieId: UUID`, `authorId: UUID`, `query: String`, `minStars: Int`, `first: Int`, `after: String` | A [connection](#connections-and-paging) of [`Review`](#review), ordered by movie then author |
| `version` | none | [`VersionInfo!`](#versioninfo) |

`query` matches anywhere in the title or the full name, ignoring case, and can be up to 100 characters. `movieId` and `authorId` filter the reviews to one movie, one author, or both.
`query` matches anywhere in the title, the full name or, on `reviews`, the review text, ignoring case, and can be up to 100 characters. `movieId` and `authorId` filter the reviews to one movie, one author, or both, and `minStars`, from 1 to 5, keeps only reviews with at least that many stars.

```graphql
{
movies(query: "global", first: 2) {
movies(query: "space", first: 2) {
totalCount
pageInfo { hasNextPage endCursor }
nodes { id title reviewCount averageStars }
Expand All @@ -37,11 +37,11 @@ Ids are the `UUID` scalar. Field and type descriptions come from the XML comment
{
"data": {
"movies": {
"totalCount": 2,
"pageInfo": { "hasNextPage": false, "endCursor": "b2Zmc2V0OjI=" },
"totalCount": 4,
"pageInfo": { "hasNextPage": true, "endCursor": "b2Zmc2V0OjI=" },
"nodes": [
{ "id": "30fca414-247a-779e-105a-d81aa2506f58", "title": "Assimilated global infrastructure", "reviewCount": 1, "averageStars": 1 },
{ "id": "c27d6600-79a6-9346-2595-a52b7f07dc3e", "title": "Automated global alliance", "reviewCount": 3, "averageStars": 3.3 }
{ "id": "cb188ef6-14e7-f85f-2f78-924c2ab26b28", "title": "Deep Space Gardeners", "reviewCount": 5, "averageStars": 3.4 },
{ "id": "dfefa450-5454-6a4d-a4aa-95a9b047c17b", "title": "Postcards from Outer Space", "reviewCount": 1, "averageStars": 3 }
]
}
}
Expand All @@ -60,10 +60,11 @@ The mutations follow Hot Chocolate's [mutation conventions](https://chillicream.

```graphql
mutation {
createReview(input: { authorId: "01fa8b58-05d2-abd4-e55c-2633222dd0a5", movieId: "e159975e-4e6a-1ffd-713e-1eb9d8d4a593", stars: 5 }) {
createReview(input: { authorId: "01fa8b58-05d2-abd4-e55c-2633222dd0a5", movieId: "cb188ef6-14e7-f85f-2f78-924c2ab26b28", stars: 5, text: "Great film. I cried at the ending." }) {
review {
id
stars
text
movie { title }
author { firstName lastName }
}
Expand Down Expand Up @@ -150,6 +151,7 @@ Paging only goes forwards. There's no `last` or `before`, and `hasPreviousPage`
| --- | --- | --- |
| `id` | `UUID!` | The review's id |
| `stars` | `Int!` | The rating, from 1 to 5 |
| `text` | `String` | What the author said about the movie, or null when there's no text |
| `movie` | `ReviewedMovie` | The movie's `id` and `title` |
| `author` | `ReviewAuthor` | The author's `id`, `firstName` and `lastName` |

Expand All @@ -167,13 +169,15 @@ Paging only goes forwards. There's no `last` or `before`, and `hasPreviousPage`
| `authorId` | `UUID!` | An existing author |
| `movieId` | `UUID!` | An existing movie |
| `stars` | `Int!` | 1 to 5 |
| `text` | `String` | Optional. Up to 1000 characters |

### UpdateReviewInput

| Field | Type | Rules |
| --- | --- | --- |
| `id` | `UUID!` | An existing review |
| `stars` | `Int!` | 1 to 5 |
| `text` | `String` | Optional. Up to 1000 characters. Leave it out to keep the text the review has |

### DeleteReviewInput

Expand Down Expand Up @@ -256,3 +260,4 @@ A query with no match doesn't error. `movie` and `author` return null, and the l
| Page size | 10 by default, 50 at most |
| Query depth | 15 |
| Search term | 100 characters |
| Review text | 1000 characters |
11 changes: 6 additions & 5 deletions src/content/docs/lambda/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@ You need the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) an

```bash
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \
-d '{"query":"global","limit":2}'
-d '{"query":"space","limit":2}'
```

You get a page of movies back:

```json
{
"items": [
{ "id": "30fca414-247a-779e-105a-d81aa2506f58", "title": "Assimilated global infrastructure", "reviewCount": 1, "averageStars": 1 },
{ "id": "c27d6600-79a6-9346-2595-a52b7f07dc3e", "title": "Automated global alliance", "reviewCount": 3, "averageStars": 3.3 }
{ "id": "cb188ef6-14e7-f85f-2f78-924c2ab26b28", "title": "Deep Space Gardeners", "reviewCount": 5, "averageStars": 3.4 },
{ "id": "dfefa450-5454-6a4d-a4aa-95a9b047c17b", "title": "Postcards from Outer Space", "reviewCount": 1, "averageStars": 3 }
],
"totalCount": 2
"totalCount": 4,
"nextOffset": 2
}
```

Yes, the movies are named by a corporate buzzword generator. *Assimilated global infrastructure* only got one star. Critics can be harsh.
The sample movies are all made up. *Deep Space Gardeners* averages 3.4 stars from five reviews, which seems fair for a film about weeding in zero gravity.

6. Run the tests while you're here.

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/lambda/guides/add-a-function.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ This guide adds a `GetMovie` function that returns one movie with all of its rev
"Presentation::WorksOnMyMachine.Reviews.Presentation.LambdaFunction.Handler_GetMovie_Generated::GetMovie"

curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \
-d '{"id":"e159975e-4e6a-1ffd-713e-1eb9d8d4a593"}'
-d '{"id":"cb188ef6-14e7-f85f-2f78-924c2ab26b28"}'
```

</Steps>
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/lambda/guides/run-locally.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ docker run --rm -p 9000:8080 -e Database__SeedSampleData=true acme-reviews:local
"Presentation::WorksOnMyMachine.Reviews.Presentation.LambdaFunction.Handler_GetReviews_Generated::GetReviews"

curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" \
-d '{"movieId":"e159975e-4e6a-1ffd-713e-1eb9d8d4a593","limit":2}'
-d '{"movieId":"cb188ef6-14e7-f85f-2f78-924c2ab26b28","limit":2}'
```

The sample data uses a fixed seed, so that movie id is the same on every machine. See the [function reference](../../reference/functions/) for every request and response.
Expand Down
Loading
Loading