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

Add note about middleware order #4431

Merged
merged 1 commit into from
Nov 16, 2021
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
4 changes: 4 additions & 0 deletions website/src/docs/hotchocolate/defining-a-schema/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public class Startup
>
> [Learn more about extending types](/docs/hotchocolate/defining-a-schema/extending-types)

A mutation type is just a regular object type, so everything that applies to an object type also applies to the mutation type (this is true for all root types).

[Learn more about object types](/docs/hotchocolate/defining-a-schema/object-types)

# Transactions

With multiple mutations executed serially in one request it can be useful to wrap these in a transaction that we can control.
Expand Down
4 changes: 3 additions & 1 deletion website/src/docs/hotchocolate/defining-a-schema/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,6 @@ public class Startup
>
> [Learn more about extending types](/docs/hotchocolate/defining-a-schema/extending-types)

A query type is just a regular [object type](/docs/hotchocolate/defining-a-schema/object-types), so we can do everything we could do with an object type with the query type (this applies to all root types).
A query type is just a regular object type, so everything that applies to an object type also applies to the query type (this is true for all root types).

[Learn more about object types](/docs/hotchocolate/defining-a-schema/object-types)
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public class Startup
>
> [Learn more about extending types](/docs/hotchocolate/defining-a-schema/extending-types)

A subscription type is just a regular object type, so everything that applies to an object type also applies to the subscription type (this is true for all all root types).

[Learn more about object types](/docs/hotchocolate/defining-a-schema/object-types)

# Transport

After defining the subscription type, we need to add the WebSockets middleware to our request pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ When using `services.AddDbContext<T>` to register a `DbContext` as a scoped serv
- `A second operation started on this context before a previous operation completed.`
- `Cannot access a disposed object.`

Fortunatley there are a couple of solutions that can be used to avoid the described issue. We will take a closer look at them in the below sections.
Fortunately there are a couple of solutions that can be used to avoid the described issue. We will take a closer look at them in the below sections.

# DbContextFactory

Expand Down Expand Up @@ -83,8 +83,10 @@ We can make this even simpler, by creating an attribute inheriting from the `Use
```csharp
public class UseSomeDbContext : UseDbContextAttribute
{
public UseSomeDbContext() : base(typeof(SomeDbContext))
public UseSomeDbContext([CallerLineNumber] int order = 0)
: base(typeof(SomeDbContext))
{
Order = order;
}
}

Expand All @@ -96,6 +98,8 @@ public class Query
}
```

> Note: Since the [order of attributes is not guaranteed by .NET](https://docs.microsoft.com/dotnet/csharp/language-reference/language-specification/attributes#attribute-specification), Hot Chocolate uses the line number to determine the correct order of the Data middleware. If you are using a custom attribute, you have to forward the line number using the `CallerLineNumberAttribute`.

</ExampleTabs.Annotation>
<ExampleTabs.Code>

Expand Down