From 0dab3ee764a876121094bcc3bd4fc6e8f3c3f68d Mon Sep 17 00:00:00 2001 From: tjeerddie Date: Thu, 20 Jul 2023 16:45:36 +0200 Subject: [PATCH] Add graphql documentation --- docs/architecture/application/graphql.md | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/architecture/application/graphql.md diff --git a/docs/architecture/application/graphql.md b/docs/architecture/application/graphql.md new file mode 100644 index 000000000..f6b3ad39a --- /dev/null +++ b/docs/architecture/application/graphql.md @@ -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) +```