-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GraphQL] Init Strawberry gql. (#33)
* start configure strawberry * feat: fix errors. * feat: init strawberry logic and architecture * fix: CI errors
- Loading branch information
1 parent
c6b128e
commit 70ede88
Showing
16 changed files
with
345 additions
and
118 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,13 @@ | ||
import strawberry | ||
|
||
from src.business_logic.favoris.get_favoris import get_favoris_by_user_id | ||
from src.business_logic.formation.scrap.types import FormationsWithTotal | ||
|
||
# https://strawberry.rocks/docs/integrations/flask#options | ||
|
||
|
||
@strawberry.type | ||
class FavorisResolver: | ||
get_favoris_by_user_id: FormationsWithTotal = strawberry.field( | ||
resolver=get_favoris_by_user_id | ||
) |
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,12 @@ | ||
from src.business_logic.formation.get_formation_details import ( | ||
FormationDetails, | ||
get_formation_by_id, | ||
) | ||
import strawberry | ||
|
||
|
||
@strawberry.type | ||
class FormationResolver: | ||
get_formation_by_id: FormationDetails = strawberry.field( | ||
resolver=get_formation_by_id | ||
) |
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,22 @@ | ||
from src.api.favoris.favori_resolver import FavorisResolver | ||
from src.api.formation.formation_resolver import FormationResolver | ||
import strawberry | ||
|
||
from strawberry.tools import merge_types | ||
from strawberry.extensions import QueryDepthLimiter | ||
from strawberry.extensions import MaxTokensLimiter | ||
from strawberry.extensions import MaxAliasesLimiter | ||
|
||
types: tuple = (FormationResolver, FavorisResolver) | ||
|
||
Queries = merge_types("Queries", types) | ||
|
||
schema = strawberry.Schema( | ||
query=Queries, | ||
extensions=[ | ||
QueryDepthLimiter(max_depth=10), | ||
MaxTokensLimiter(max_token_count=1000), | ||
MaxAliasesLimiter(max_alias_count=15), | ||
], | ||
) | ||
# https://strawberry.rocks/docs/guides/tools |
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,12 @@ | ||
from flask import Blueprint, Response | ||
from strawberry.flask.views import GraphQLView | ||
|
||
from src.api.schema import schema | ||
|
||
graphql = Blueprint("graphql", __name__, url_prefix="/api/graphql") | ||
|
||
|
||
@graphql.route("/", methods=["POST", "GET"]) | ||
def gql() -> tuple[Response, int]: | ||
view = GraphQLView.as_view("graphql_view", schema=schema) | ||
return view() |
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
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from dataclasses import dataclass | ||
import strawberry | ||
|
||
|
||
@dataclass | ||
@strawberry.type | ||
class Job: | ||
id: str | ||
libelle: str | ||
|
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
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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
from dataclasses import dataclass | ||
|
||
import strawberry | ||
|
||
from src.models.formation import Formation | ||
|
||
|
||
@dataclass | ||
@strawberry.type | ||
class Facet: | ||
key: str | ||
doc_count: int | ||
|
||
|
||
@dataclass | ||
@strawberry.type | ||
class FormationIsFavorite: | ||
formation: Formation | ||
is_favorite: bool | ||
|
||
|
||
@dataclass | ||
@strawberry.type | ||
class FormationsWithTotal: | ||
total: int | ||
formations: list[Formation | FormationIsFavorite] |
3 changes: 3 additions & 0 deletions
3
src/business_logic/formation/study/get_continuation_of_study.py
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
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
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
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