cppgraphqlgen icon indicating copy to clipboard operation
cppgraphqlgen copied to clipboard

Fragments should generate their own structs

Open JamesPeters98 opened this issue 2 years ago • 0 comments
trafficstars

When generating a client using fragments and lots of similar queries that use the same fragment it leads to lots of the same structs being generated.

Ideally there would be a seperate Fragments struct that contains the defined fragments.

I.e the following queries would both share the same response structs as they use the same fragment:

fragment LoadInfo on Load {
    loadId
    jobContainerId
    name
    loadPlanStatus
    journey {
        journeyId
    }
}

query loadById($load: Int!) {
    loadByID(loadId: $load) {
        ...LoadInfo
    }
}

query loadBySupplier($supplier: String!, $after: LocalDateTime!) {
    loadsBySupplierId(supplierCode: $supplier, after: $after) {
        ...LoadInfo
    }
}

Not sure how feasible that is, but I think something similar is done for input types and enums?

JamesPeters98 avatar Jan 25 '23 13:01 JamesPeters98