Skip to content

Commit

Permalink
Add scalars to extract operation plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alzex3 committed Jan 7, 2024
1 parent 184f9f2 commit badc2da
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/main/clients/operations/expected_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
C_SUBSCRIPTION_GQL,
GET_A_GQL,
GET_A_WITH_FRAGMENT_GQL,
GET_S_GQL,
GET_XYZ_GQL,
)
from .exceptions import (
Expand All @@ -26,6 +27,7 @@
GetAWithFragmentA,
GetAWithFragmentAValueB,
)
from .get_s import GetS, GetSS
from .get_xyz import GetXYZ, GetXYZXyzTypeX, GetXYZXyzTypeY, GetXYZXyzTypeZ

__all__ = [
Expand All @@ -42,13 +44,16 @@
"FragmentY",
"GET_A_GQL",
"GET_A_WITH_FRAGMENT_GQL",
"GET_S_GQL",
"GET_XYZ_GQL",
"GetA",
"GetAA",
"GetAAValueB",
"GetAWithFragment",
"GetAWithFragmentA",
"GetAWithFragmentAValueB",
"GetS",
"GetSS",
"GetXYZ",
"GetXYZXyzTypeX",
"GetXYZXyzTypeY",
Expand Down
10 changes: 10 additions & 0 deletions tests/main/clients/operations/expected_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
C_SUBSCRIPTION_GQL,
GET_A_GQL,
GET_A_WITH_FRAGMENT_GQL,
GET_S_GQL,
GET_XYZ_GQL,
)
from .get_a import GetA
from .get_a_with_fragment import GetAWithFragment
from .get_s import GetS
from .get_xyz import GetXYZ


Expand Down Expand Up @@ -77,3 +79,11 @@ async def get_xyz(self, **kwargs: Any) -> GetXYZ:
)
data = self.get_data(response)
return GetXYZ.model_validate(data)

async def get_s(self, **kwargs: Any) -> GetS:
variables: Dict[str, object] = {}
response = await self.execute(
query=GET_S_GQL, operation_name="getS", variables=variables, **kwargs
)
data = self.get_data(response)
return GetS.model_validate(data)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"C_SUBSCRIPTION_GQL",
"GET_A_GQL",
"GET_A_WITH_FRAGMENT_GQL",
"GET_S_GQL",
"GET_XYZ_GQL",
]

Expand Down Expand Up @@ -68,3 +69,11 @@
valueY
}
"""

GET_S_GQL = """
query getS {
s {
id
}
}
"""
9 changes: 9 additions & 0 deletions tests/main/clients/operations/expected_client/get_s.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .base_model import BaseModel


class GetS(BaseModel):
s: "GetSS"


class GetSS(BaseModel):
id: int
3 changes: 3 additions & 0 deletions tests/main/clients/operations/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ target_package_name = "client_with_operations"
include_comments = "none"
plugins = ["ariadne_codegen.contrib.extract_operations.ExtractOperationsPlugin"]

[tool.ariadne-codegen.scalars.CUSTOMID]
type = "int"

[tool.ariadne-codegen.extract-operations]
operations_module_name = "custom_operations"
6 changes: 6 additions & 0 deletions tests/main/clients/operations/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ query getXYZ {
}
}
}

query getS {
s {
id
}
}
7 changes: 7 additions & 0 deletions tests/main/clients/operations/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
scalar CUSTOMID

type Query {
constQuery: String!
a: TypeA!
s: TypeS!
xyz: TypeXYZ!
}

Expand All @@ -21,6 +24,10 @@ type TypeB {
value: String!
}

type TypeS {
id: CUSTOMID!
}

type TypeX {
valueX: String!
}
Expand Down

0 comments on commit badc2da

Please sign in to comment.