shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.1k stars 89 forks source link

Recursive types #81

Open nyarly opened 3 years ago

nyarly commented 3 years ago

I don't think there's a way to represent this in GraphQL, but I experimented with:

type treeObject struct {
    Tree struct {
        Entries []struct {
            Path   string
            Object treeObject
        }
    } `graphql:"... on Tree"`
    Blob struct {
        byteSize int
    } `graphql:"... on Blob"`
}

which resulted in a stack overflow panic.

The appropriate type is going to be irritating to write, but an error rather than a panic would be nice here.

dmitshur commented 3 years ago

Also see past discussion in shurcooL/graphql#9.