Mixin not stripped from Fragments (take 2)
I'm still seeing issues when adding a @mixin to a fragment. I saw https://github.com/mirumee/ariadne-codegen/issues/176, but the issue persists. In my case, I'm trying to add the mixin to the fragment itself, not a field within the fragment.
sample-schema.graphql
type Item {
id: ID
}
type Mutation {
change_item(id: ID!): Item
}
sample-queries.graphql
fragment Item on Item @mixin(from: "sample_mixin", import: "ItemMixin") {
id
}
mutation my_mutation($id: ID!) {
change_item(id: $id) {
...Item
}
}
sample_mixin.py
class ItemMixin:
pass
sample.toml
[tool.ariadne-codegen]
schema_path = "sample-schema.graphql"
queries_path = "sample-queries.graphql"
Running ariadne-codegen --config sample.toml results in a client.py that looks like this:
class Client(AsyncBaseClient):
async def my_mutation(self, id: str, **kwargs: Any) -> MyMutation:
query = gql(
"""
mutation my_mutation($id: ID!) {
change_item(id: $id) {
...Item
}
}
fragment Item on Item @mixin(from: "sample_mixin", import: "ItemMixin") {
id
}
"""
)
variables: Dict[str, object] = {"id": id}
response = await self.execute(
query=query, operation_name="my_mutation", variables=variables, **kwargs
)
data = self.get_data(response)
return MyMutation.model_validate(data)
$ pip list | grep ariadne
ariadne-codegen 0.13.0
I confirm this doesn't work currently. Seems like the PR in the other issue addresses only the part when the mixin is defined in a field, not on the entire fragment.
@dhay I've just rechecked today and got surprised as besides obviously wrong GraphQL code, my queries are still working with the unstripped mixin directive, I have no idea why. Does it fail for you?
It’s definitely still an issue. In fact I just ran into it again in another project I was recently working on. Maybe it depends on which server implantation is in play? We’re using the Node.js federation server. Perhaps it’s more strict about GraphQL syntax than other servers?
It’s definitely still an issue. In fact I just ran into it again in another project I was recently working on. Maybe it depends on which server implantation is in play? We’re using the Node.js federation server. Perhaps it’s more strict about GraphQL syntax than other servers?
Probably. I'm using Hasura and it's quite surprisingly letting this one go
Same issue here