Package version
graphql-zeus: 7.2.1
Problem
When an enum argument is used on a field selected inside an inline fragment, Zeus serializes the enum value as a quoted string.
GraphQL enums must be serialized without quotes. The generated query is therefore rejected by GraphQL servers.
Minimal schema
type Query {
items: [Item!]!
}
type Item {
nested(filter: [NestedFilter!]): [Nested!]!
}
type Nested {
id: ID!
}
enum NestedFilter {
ACTIVE
ARCHIVED
}
Reproduction
import {Zeus, NestedFilter} from './zeus';
const queryWithoutInlineFragment = Zeus('query', {
items: {
nested: [
{filter: [NestedFilter.ACTIVE]},
{
id: true
}
]
}
});
console.log(queryWithoutInlineFragment);
const queryWithInlineFragment = Zeus('query', {
items: {
'...on Item': {
nested: [
{filter: [NestedFilter.ACTIVE]},
{
id: true
}
]
}
}
});
console.log(queryWithInlineFragment);
Actual result
Without inline fragment, the enum is serialized correctly:
query {
items {
nested(filter: [ACTIVE]) {
id
}
}
}
With inline fragment, the enum is serialized as a string:
query {
items {
...on Item {
nested(filter: ["ACTIVE"]) {
id
}
}
}
}
Expected result
The enum should also be serialized without quotes inside inline fragments:
query {
items {
...on Item {
nested(filter: [ACTIVE]) {
id
}
}
}
}
Suspected cause
The generated Zeus query builder resolves argument types through an internal string path in InternalArgsBuilt(...) / ResolveFromPath(...).
For the normal case, the argument path can be resolved to something equivalent to:
Item.nested.filter -> NestedFilter -> enum
Inside an inline fragment, the internal path appears to include the inline fragment as if it were a real field:
Query | items | ...on Item | nested | filter
Since ...on Item is not a real schema field, the type lookup fails. Zeus no longer recognizes filter as an enum argument and falls back to normal string serialization.
There already seems to be inline-fragment-specific path handling in PrepareScalarPaths(...), where inline fragments are not added to the scalar response path. Similar handling may be needed for argument path construction in InternalsBuildQuery(...) / InternalArgsBuilt(...).
Related issue
This may be related to #425, which also appears to involve nested argument type resolution, but this case affects enum serialization rather than scalar encoding.
(description generated with ai)
Package version
graphql-zeus:7.2.1Problem
When an enum argument is used on a field selected inside an inline fragment, Zeus serializes the enum value as a quoted string.
GraphQL enums must be serialized without quotes. The generated query is therefore rejected by GraphQL servers.
Minimal schema
Reproduction
Actual result
Without inline fragment, the enum is serialized correctly:
With inline fragment, the enum is serialized as a string:
Expected result
The enum should also be serialized without quotes inside inline fragments:
Suspected cause
The generated Zeus query builder resolves argument types through an internal string path in InternalArgsBuilt(...) / ResolveFromPath(...).
For the normal case, the argument path can be resolved to something equivalent to:
Inside an inline fragment, the internal path appears to include the inline fragment as if it were a real field:
Since ...on Item is not a real schema field, the type lookup fails. Zeus no longer recognizes filter as an enum argument and falls back to normal string serialization.
There already seems to be inline-fragment-specific path handling in PrepareScalarPaths(...), where inline fragments are not added to the scalar response path. Similar handling may be needed for argument path construction in InternalsBuildQuery(...) / InternalArgsBuilt(...).
Related issue
This may be related to #425, which also appears to involve nested argument type resolution, but this case affects enum serialization rather than scalar encoding.
(description generated with ai)