-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# GraphQL documentation | ||
|
||
OrchestratorCore comes with a graphql interface that can to be registered after you create your OrchestratorApp. | ||
If you add it after registering your `SUBSCRIPTION_MODEL_REGISTRY` it will automatically create graphql types for them. | ||
|
||
example: | ||
```python | ||
app = OrchestratorCore(base_settings=AppSettings()) | ||
# register SUBSCRIPTION_MODEL_REGISTRY | ||
app.register_graphql() | ||
``` | ||
|
||
## Extending the Query and Mutation | ||
|
||
This is an basic example of how to extend the query. | ||
You can do the same to extend Mutation. | ||
|
||
```python | ||
from orchestrator.graphql import Query, Mutation | ||
|
||
|
||
# Queries | ||
def resolve_new(info) -> str: | ||
return "resolve new..." | ||
|
||
|
||
@strawberry.federation.type(description="Orchestrator queries") | ||
class NewQuery(Query): | ||
other_processes: Connection[ProcessType] = authenticated_field( | ||
resolver=resolve_processes, | ||
description="resolve_processes used for another field", | ||
) | ||
new: str = strawberry.field(resolve_new, description="new resolver") | ||
|
||
|
||
app = OrchestratorCore(base_settings=AppSettings()) | ||
# register SUBSCRIPTION_MODEL_REGISTRY | ||
app.register_graphql(query=NewQuery) | ||
``` |