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: add scalar kind #7158
feat: add scalar kind #7158
Conversation
fef52da
to
c6a99ae
Compare
A fun side-effect I just discovered - because of how dagql does enums, we get enum support included alongside this! |
7567e99
to
63973ac
Compare
I'll get on that asap and coordinate with @TomChv. Thanks for pushing this through! 🙏 |
Asking for #6967, is |
@wingyplus, yes, |
e95637c
to
5a3d325
Compare
32a9d04
to
1471be4
Compare
@helderco should be ready for another review now - do we want to land the typescript/python work in the context of this PR, or do we want to follow-up in later PRs? |
It's more important to be in the same release than in the same PR. I've already made the change for Python locally but in holiday today and the tests need improvement. I asked Tom to do the same but it may not be as easy there because of how it's written. Hold on at least for Python and I'll check up with Tom. |
Rebased, since main is a little less flaky right now 🎉 |
@jedevc, needs a change log. SDKs not needed, I think. Just core. |
@helderco will do - looks like |
Ah, forgot about those. Will fix in a minute 🙏 |
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
@jedevc, user created enums are actually very useful to support (instead of custom scalars): |
This implies some changes in the TS SDK to support enumeration but it shouldn't be a big deal. |
Yeah this is actually a bit more of a pain in go since native enum types aren't really a thing. I'm happy for someone else to lead on the custom enums work and I can work out how it makes sense in go, but probably makes sense to lead with a language that actually supports them nicely 😆 See main...jedevc:dagger:add-custom-scalar-kind for a base for how to handle the custom scalar plumbing (enums are pretty similar to enums for this). |
I think Go's implementation of enums is fine. Custom scalars are more problematic because their implementation has to define:
That can be simplified if we just assume/limit to a normal string everywhere, but it still opens a can of worms when we don't have enough feedback that it's actually needed. However with enums, it's just a fixed list of supported string values. No serialization/deserialization required. To support defining new enums via the API it’s similar to type EnumTypeDef {
name: String!
description: String!
values: [EnumValueTypeDef!]!
}
type EnumValueTypeDef {
name: String!
description: String!
}
type TypeDef {
"""
If kind is ENUM_KIND, the enum-specific type definition.
If kind is not ENUM_KIND, this will be null.
"""
asEnum: EnumTypeDef
"""
Returns a TypeDef of kind Enum with the provided name.
Note that an enum's values may be omitted if the intent is only to refer to an enum.
This is how functions are able to return their own, or any other circular reference.
"""
withEnum(name: String!, description: String = ""): TypeDef!
"""
Adds a static value for an Enum TypeDef, failing if the type is not an enum.
"""
withValue(name: String!, description: String = ""): TypeDef!
}
enum TypeDefKind {
"""
A GraphQL enum type and its values.
Always paired with an EnumTypeDef.
"""
ENUM_KIND
} |
* chore: remove unneccessary InputType Signed-off-by: Justin Chadwell <[email protected]> * chore: format mod typedef query Signed-off-by: Justin Chadwell <[email protected]> * chore: avoid ModuleObjectType typed nil Signed-off-by: Justin Chadwell <[email protected]> * feat: add scalar typedefs to propagate scalars Signed-off-by: Justin Chadwell <[email protected]> * feat: interpret current arg to get current platform Signed-off-by: Justin Chadwell <[email protected]> * Add Python fix Signed-off-by: Helder Correia <[email protected]> * Replace ignored stdout with sync Signed-off-by: Helder Correia <[email protected]> * fix test to-platform Signed-off-by: Justin Chadwell <[email protected]> * Test return values and enum types Signed-off-by: Helder Correia <[email protected]> * Fix linter on changed function Signed-off-by: Helder Correia <[email protected]> * chore: regen rust Signed-off-by: Justin Chadwell <[email protected]> * feat: support scalar in TypeScript Signed-off-by: Tom Chauveau <[email protected]> * feat: add enum tests Signed-off-by: Tom Chauveau <[email protected]> * Remove old tests Signed-off-by: Helder Correia <[email protected]> * Add change log Signed-off-by: Helder Correia <[email protected]> --------- Signed-off-by: Justin Chadwell <[email protected]> Signed-off-by: Helder Correia <[email protected]> Signed-off-by: Tom Chauveau <[email protected]> Co-authored-by: Helder Correia <[email protected]> Co-authored-by: Tom Chauveau <[email protected]>
DEV-3403
Fixes #6466
This is the "proper" implementation of #6739. This allows us to preserve the original scalar name.
Implemented functionality:
TypeDef
s have anAsScalar
field, so that they can be connected to their original value.dagger.Platform
flag. Eventually, this could allow us to have a special value, like"current"
as a shorthand to represent the client platform.WithScalar
to define their own non-core scalar values - these are represented as scalars inTypeDef
s, as well as in the GraphQL schema.TODO:
dagger.Platform
(this was my motivation for doing all this lol)