crashappsec / gql_schema_codegen

A module to generate Python typings from a GrapqhQL schema
MIT License
0 stars 1 forks source link

Handle interfaces in generated classes #2

Closed nettrino closed 1 year ago

nettrino commented 1 year ago

Currently types that implement a given interface are not translated to the appropriate inherited classes. For instance , given the following gql definitions:

interface ResourceEntity {
    id: ID! @id(autogenerate: false)
    name: String
    type: ResourceType!
}

type Resource implements ResourceEntity {
...
}

type Repository implements ResourceEntity {
    id: ID! @id(autogenerate: false)
...
}

...

type Issue {
    id: ID! @id(autogenerate: false)
     ...
    resources: [ResourceEntity!]! @relationship(type: "HAS_ISSUE", direction: IN)
}

we would want Issue to accept any of Repository / Resource. That said, we would not want to affect any of the neo4j autogenerated classes like CreateResourceInput etc.

nettrino commented 1 year ago

Should be addressed in https://github.com/crashappsec/gql_schema_codegen/pull/3/files