#al1000 started by just seeing what
1 messages · Page 1 of 1 (latest)
It understands extend but the problem is that a schema like this:
extend type Query {
alpine: Alpine!
}
type Alpine {
build(pkgs: [String!]): Filesystem!
}
results in an implementation stub like this being generated:
func (r *queryResolver) Alpine(ctx context.Context) (*Alpine, error) {
panic("not implemented")
}
gqlgen won't generate methods for subresolvers unless explicitly configured to do (even if the fields take args, which makes no sense to me): https://github.com/99designs/gqlgen#using-explicit-resolvers
Explicitly configuring that is not straightforward to put in our generic tool, but even if we did here's what the generated code ends up looking like:
func (r *alpineResolver) Build(ctx context.Context, obj *Alpine, pkgs []string) (*dagger.Filesystem, error) {
panic("not implemented")
}
func (r *queryResolver) Alpine(ctx context.Context) (*Alpine, error) {
panic("not implemented")
}
I'm looking to see if there's anything else configurable, but I'm suspecting we may need to either:
- Continue doing some schema mangling for now
- Customize our gqlgen plugin even more
- Move away from gqlgen entirely, replace with the language agnostic tool we've talked about
Gonna start with 2. above just to see if we can get away with anything quickly.
I think it has something to do with model binding
by default, it just assumes everything is a model (e.g. the whole Alpine is a type)
so uhm, I think for instance of auto binding is enabled, it will assume that if it doesn't find a model, then it should generate the resolver
(don't remember the specifics, but it was working out just fine in the core-gqlgen branch)
Yeah I tried playing around with model binding settings, but couldn't get it to skip trying to define Alpine(...).
It looks like it was generating top level resolvers for the type right under query in that branch, unless I am misunderstanding: https://github.com/dagger/cloak/blob/core-gqlgen/core/query.resolvers.go
No worries, I just wanted to see if you had any ideas quick, yeah I was just trying per schema to see if it made a difference
for instance, for those it decided to have resolvers on its own
(i don't have a single "force resolver" in that branch and it turned out ok)
(For when you're free)
Gave the follow-schema plugin a try w/ alpine but still wasn't getting the expected behavior. So I went back to the branch you linked to and tried it there.
Do you remember how you set up this model directory? https://github.com/dagger/cloak/tree/core-gqlgen/core/model
The autobind setting in your gqlgen.yml which points to that dir seems to be key; when I unset that I go back to the behavior I'm seeing w/ alpine where no methods for subresolvers are generated.
The problem is that I can't figure out how this gets bootstrapped. I tried:
- Delete all the go files, including
modelandgenerated, leave only aserver.gowithgo generatecommand at top, nothing else - Run
go generate server.go- That errors out saying that
github.com/dagger/cloak/core/modeldoesn't exist
- That errors out saying that
- Unset the
autobindkey ingqlgen.yml - Run
go generate server.goagain, succeeds now- However, it does not have the subresolvers, same problem as alpine before.
- Re-add the
autobindkey togqlgen.yml - Run
go generate server.goagain, errors out withunable to load github.com/dagger/cloak/core/model- There are contents in
modelbefore this command, it seems like they get deleted and then it errors out?
- There are contents in
Was there a magic incantation to get this working before?