Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2/pkg/astprinter] astprinter does not output which interfaces given transitive interface implements #1018

Open
lorf opened this issue Dec 18, 2024 · 0 comments · May be fixed by #1021
Open

Comments

@lorf
Copy link

lorf commented Dec 18, 2024

Description

Package v2/astprinter missing feature: it does not print which interfaces given transitive interface implements

Sample source code

Given the following source code

package main

import (
    "fmt"

    "github.com/wundergraph/graphql-go-tools/v2/pkg/ast"
    "github.com/wundergraph/graphql-go-tools/v2/pkg/astparser"
    "github.com/wundergraph/graphql-go-tools/v2/pkg/astprinter"
)

func main() {
    d, _ := astparser.ParseGraphqlDocumentString(`
        interface I1 {
            id: ID
        }
        interface I2 implements I1 {
            id: ID
        }
    `)

    out, _ := astprinter.PrintStringIndent(&d, "  ")
    fmt.Println(out)

    // Demonstrate that document's internal structure is correct
    for _, n := range d.RootNodes {
        if n.Kind == ast.NodeKindInterfaceTypeDefinition {
            for _, iRef := range d.InterfaceTypeDefinitions[n.Ref].ImplementsInterfaces.Refs {
                fmt.Printf("# Interface %v implements %v\n", d.NodeNameBytes(n),
                    d.ResolveTypeNameBytes(iRef))
            }
        }
    }
}

Expected result

I expected to see the following result (interface I2 definition implements I1):

interface I1 {
    id: ID
}

interface I2 implements I1 {
    id: ID
}
# Interface I2 implements I1

Actual result

What i've got (interface I2 definition DOES NOT implements I1):

interface I1 {
    id: ID
}

interface I2 {
    id: ID
}
# Interface I2 implements I1
lorf added a commit to lorf/graphql-go-tools that referenced this issue Dec 29, 2024
Just copied relevant part from EnterObjectTypeDefinition()

Also add tests

Fixes wundergraph#1018
lorf added a commit to lorf/graphql-go-tools that referenced this issue Dec 29, 2024
Just copied relevant part from EnterObjectTypeDefinition()

Also add tests

Fixes wundergraph#1018
lorf added a commit to lorf/graphql-go-tools that referenced this issue Dec 29, 2024
Just copied relevant part from EnterObjectTypeDefinition()

Also add tests

Fixes wundergraph#1018
lorf added a commit to lorf/graphql-go-tools that referenced this issue Dec 29, 2024
Just copied relevant part from EnterObjectTypeDefinition()

Also add tests

Fixes wundergraph#1018
@lorf lorf linked a pull request Dec 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant