-
Notifications
You must be signed in to change notification settings - Fork 623
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
feat: improved navigation for codegen #8498
Conversation
d1b2ddf
to
17a297b
Compare
This PR should now be ready to review, it's not 100% feature complete, since it's missing other language support, but IMO it's a good enough starting point to get in. |
17a297b
to
8a10669
Compare
e98b5da
to
9febdfc
Compare
Woo, think I've really got the edge cases now. I've also split it out into smaller commits to make it easier to review. |
func (d *DirectiveApplication) Type() *ast.Type { | ||
return &ast.Type{ | ||
// Some clients don't like custom introspection types like this :( | ||
// NamedType: "__DirectiveApplication", | ||
NamedType: "_DirectiveApplication", | ||
NonNull: true, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to the reviewer: this is very sad 😢
Ideally, I'd love to be able to define our own "internal" types, and it looked for a while like I could, but python's graphql-core really did not like this: https://github.com/graphql-python/graphql-core/blob/4e83d4201a2be88832f24c5733c0a1b8568c3708/src/graphql/type/validate.py#L181-L196
So, we can just use a single underscore here, and just modify the codegen for the clients to handle this case.
if strings.HasPrefix(schemaType.Name, "_") { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to the reviewer: this change is required because previously we were relying on graphql's typescript library to filter out __
prefixes when creating a schema from an introspection result.
But, with the change to use _
prefixes for "dagger internal" in some places, we need an extra processing step here that we didn't need before.
9febdfc
to
9e8bfa5
Compare
8197b98
to
b9c22de
Compare
b9c22de
to
6d5860e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
cmd/codegen/generator/generator.go
Outdated
@@ -34,6 +34,8 @@ type Config struct { | |||
ModuleName string | |||
// ModuleContextPath is the subpath where a module can be found. | |||
ModuleContextPath string | |||
// ModuleParentPath is the path from the subpath to the output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can this comment be clarified more? The one you have later of // path from the module root to the context
was helpful and parsable by my brain 😄
I got this working for the type values previously in 87aed89, but woops - we also need it for the type itself. Signed-off-by: Justin Chadwell <me@jedevc.com>
Previously, only the python SDK was filtering out any types beginning with a single underscore "_" - all the other SDKs + APIs were assuming that only the double underscore should be filtered out "__". However, because we want to add our own internal types (and we can't add double underscore prefixes, grr), then we should also filter out any underscored type (which seems absolutely fine to do). Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
6d5860e
to
0211ad5
Compare
Signed-off-by: Justin Chadwell <me@jedevc.com>
This is kind of a bundle of various different patches all to enable "better multi-module navigation". With the incoming work in #8355, we're gonna have even more modules than we currently do today (and we already have a few). Working on a multi-module project is quite difficult, and it's challenging to navigate between functions defined in different modules.
The end goal is to produce something like this (for a module
dep
that contains aContainerEcho
function), note thedep/src/main.go:31
at the end of the function declaration:Most IDEs include support clicking on this link, and navigating to the right place automatically - a future IDE plugin could automatically find this and jump to it.
To do this:
dagql
server though, we can extend this ourselves../path/to/filename:line
next to the generated code.TODO: