Skip to content

Aliases not generated in GraphQL query #142

Description

@zahidashiq

Describe the bug

When executing a GraphQL query with multiple operations using aliases (e.g., A and B), ZeroQL does not include the aliases in the generated GraphQL query. This prevents fetching multiple entities in a single request when they use the same GraphQL operation but different filters.

How to Reproduce

var filterA = new UserA { ExtRef = "80012" };
var filterB = new UserB { ExtRef = "545421" };

var response = await client.Query(q => new
{
A = q.UserByRefNo(filterA, user => new { /* fields / }),
B = q.UserByRefNo(filterB, user => new { /
fields */ })
});

Expected behavior

he generated GraphQL query should include aliases:
query {
A: userByRefNo(filter: { extRef: "80012" }) { /* fields / }
B: userByRefNo(filter: { extRef: "545421" }) { /
fields */ }
}

Actual behavior
The generated query lacks aliases, resulting in an invalid/malformed query or unexpected behavior:
query {
userByRefNo(filter: { extRef: "80012" }) { /* fields / }
userByRefNo(filter: { extRef: "545421" }) { /
fields */ }
}

Environment:
. NuGet package version: 7.0.3
. IDE: Visual Studio 2022
. NET Version: 9.0.100

Additional context
. Works fine when making separate queries
. Issue occurs only when trying to alias multiple calls to the same query method
. Confirmed the same behavior exists when using explicit types instead of anonymous objects
. ZeroQL appears to ignore property names when generating the query

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions