Skip to content

Conversation

@tomoikey
Copy link
Contributor

@tomoikey tomoikey commented Feb 7, 2026

Description

Some of the code currently living in the templates doesn't need to be part of the generated output. Moving these pieces into static .go files helps keep generated.go simpler and easier to maintain.

There are several places where this applies, so I'll be sending a series of smaller PRs rather than one large change. As a first step, this PR extracts the Config struct into the graphql package.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@tomoikey tomoikey force-pushed the refactor/generated-go branch from d636ef0 to 24df78f Compare February 7, 2026 07:45
@tomoikey tomoikey marked this pull request as draft February 7, 2026 07:47
Comment on lines -24 to -35
eq, msg := eqgo.PackagesEquivalent(
singlefilePkg,
singlefileFSet,
followschemaPkg,
followschemaFSet,
nil,
)
if !eq {
// When msg is too long, require.True(...) omits it entirely.
// Therefore use fmt.Fprintln to print it manually instead.
fmt.Fprintln(os.Stderr, msg)
require.Fail(t, "Packages not equivalent")
Copy link
Contributor Author

@tomoikey tomoikey Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eq-go does not support Go 1.18 generics (ast.IndexListExpr) and panics when it encounters them.
Since the library is no longer maintained, this PR replaces it with comparison using the standard library's go/printer.

type Config[R any, D any, C any] struct {
	Schema     *ast.Schema
	Resolvers  R
	Directives D
	Complexity C
}

@coveralls
Copy link

Coverage Status

coverage: 0.0%. remained the same
when pulling a7d8cc5 on tomoikey:refactor/generated-go
into 6eaef21 on 99designs:master.

Comment on lines +70 to +72
if gd, ok := decl.(*ast.GenDecl); ok && gd.Tok == token.IMPORT {
continue
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This skips import comparison. Since matching declarations will inherently produce matching imports, there's little value in comparing them separately. It also avoids some awkward edge cases around import handling. I don't think this causes any real problems in practice.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

@tomoikey tomoikey marked this pull request as ready for review February 7, 2026 18:42
@StevenACoffman StevenACoffman merged commit 6107d5a into 99designs:master Feb 10, 2026
18 checks passed
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 this pull request may close these issues.

3 participants