Skip to content

implement new conventions for IDable objects - #5881

Merged
vito merged 10 commits into
dagger:mainfrom
vito:idable-refactor
Oct 12, 2023
Merged

vito merged 10 commits into
dagger:mainfrom
vito:idable-refactor

Conversation

@vito

@vito vito commented Oct 12, 2023 •

Copy link
Copy Markdown
Contributor

This is an assorted set of sweeping changes that fix the longstanding bug involved with traversing lists of ID-able objects in the SDK. We've worked around this issue about 10 times in the past two weeks, and now I understand why!

In short, we need a reliable way to go from foos: [Foo!]! to selecting the Nth Foo and querying against it.

In Go this looks like the following, which actually panics prior to this PR:

funs, _ := mod.Functions(ctx)
for _, fun := range funs {
  fun.Name(ctx) // BOOM
}

This was panicking because the implementation for returning lists of objects only dealt with scalars, leaving the rest of the object "hollow" (no q and c fields). It could have populated c, but q was impossible: how do you chain queries from the Nth element in a list? If you had a list of ID-able objects you could at least query them by ID and chain from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level loadFooFromID(id: FooID!): Foo! resolver. That means when an SDK sees a list of [Foo!]! objects, it knows it can just fetch IDs and then create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new core/schema/ helper for registering resolvers that follow this pattern, to help cut down on a ton of boilerplate:

func (s *moduleSchema) Resolvers() Resolvers {
	rs := Resolvers{}

	// also adds ModuleID scalar + resolvers for Module { id }, Query { loadModuleFromID }
	ResolveIDable[core.Module](rs, "Module", ObjectResolver{
		"withObject":    ToResolver(s.moduleWithObject),
		"generatedCode": ToResolver(s.moduleGeneratedCode),
		"serve":         ToVoidResolver(s.moduleServe),
	})

	return rs
}

Now that there's a dedicated constructor for objects from their ID we can start removing the optional id: arg from other constructors, which also means that ID-able objects can now be constructed with required args. I applied this change to GeneratedCode, Module, and Function, and deprecated the id: args everywhere else.

BREAKING: Along the way, I had to rename CacheID to CacheVolumeID. This has long been a thorn in every SDK developer's side, since it's the only ID type that doesn't match its corresponding object type. We're about to make breaking changes for Services v2 so I figure this is worth doing now.

Also, bumps graphql-go-tools to a version that doesn't just swallow schema errors and result in cryptic second-order runtime errors.

Also, removes the various maps from Go/NodeJS codegen that required maintaining a list of ID types and other scalar types.

@vito
vito requested review from a team as code owners October 12, 2023 02:22
vito added 3 commits October 11, 2023 22:27
This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@vito
vito requested a review from a team as a code owner October 12, 2023 02:37
* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@vito vito added the kind/breaking Breaking Change label Oct 12, 2023
Signed-off-by: Alex Suraci <[email protected]>

@helderco helderco left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for the kudos noise 🙂 It looks good to me, apart from missing Kind argument in graphql. Trying it locally seems to be working.

Comment on lines +104 to +107
"""
Create a new TypeDef with a given kind.
"""
typeDef: TypeDef!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"given kind"? I suppose you meant to add a "kind" argument?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah woops - I had an intermediate state where it took a required kind argument with the goal of avoiding partial instantiation, but I rolled that back; it's kind of nice to be able to skip it since it's set for you by withListOf and withObject, and it didn't fix partial instantiation anyway since for lists you need the element type, and for objects you need a name/etc.

Comment on lines -179 to +183
{{ if eq ($.Name | FormatName) "Container" }}
*r = *dag.Container(ContainerOpts{
ID: ContainerID(id),
})
{{ else if eq ($.Name | FormatName) "Directory" }}
*r = *dag.Directory(DirectoryOpts{
ID: DirectoryID(id),
})
{{ else if eq ($.Name | FormatName) "Socket" }}
*r = *dag.Socket(SocketOpts{
ID: SocketID(id),
})
{{ else if eq ($.Name | FormatName) "Module" }}
*r = *dag.Module(ModuleOpts{
ID: ModuleID(id),
})
{{ else if eq ($.Name | FormatName) "Function" }}
*r = *dag.Function(FunctionID(id))
{{ else if eq ($.Name | FormatName) "File" }}
*r = *dag.File(FileID(id))
{{ else if eq ($.Name | FormatName) "Secret" }}
*r = *dag.Secret(SecretID(id))
{{ else if eq ($.Name | FormatName) "Cache" }}
cacheID := CacheID(id)
*r = CacheVolume{
q: dag.q,
c: dag.c,
id: &cacheID,
}
{{ end }}
*r = *dag.Load{{ $.Name | FormatName }}FromID({{$.Name | FormatName}}ID(id))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank goodness 🙏

Comment thread core/schema/file.graphqls Outdated
"Loads a file by ID."
file(id: FileID!): File
"Loads a file by ID."
file(id: FileID!): File @deprecated(reason: "Use loadFileFromID instead.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
file(id: FileID!): File @deprecated(reason: "Use loadFileFromID instead.")
file(id: FileID!): File @deprecated(reason: "Use `loadFileFromID` instead.")

Backticks on field references in deprecation messages get interpreted by the sdks to convert naming convention.

Comment thread sdk/go/modules/sdks.go
// one wants to type dagger mod init --sdk=github.com/dagger/dagger-sdk-go.
var WellKnownSDKRuntimes = map[string]string{
"go": "vito/dagger-sdk-go:no-ptrs@sha256:2bb26bae3f30b920a4530b7495127fe4986102b06a99ff170500e83c25739b27",
"go": "vito/dagger-sdk-go:f239c6f6c3ceaa1f760b589fac43b1d0704e45d3@sha256:915f41b414b12a878c60d96869f8ff8155e6ce122b1849303b995b65a343591f",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tag based on git commit 👍

Comment on lines +218 to +220
@classmethod
def _from_id_query_field(cls):
return "loadCacheVolumeFromID"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now this can be removed since the field name is predictable now 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh nice! I started pulling on this thread but ran into unfamiliar areas of code, so I'll just prioritize merging this for now to unblock your other PR

Comment thread cmd/dagger/call.go
Comment on lines -86 to -95
// TODO: workaround bug in codegen
objID, err := def.ID(ctx)
if err != nil {
return fmt.Errorf("failed to get object id: %w", err)
}
def = *dag.TypeDef(
dagger.TypeDefOpts{
ID: objID,
},
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank god 🙌

vito added 3 commits October 12, 2023 14:02
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit 7393e19 into dagger:main Oct 12, 2023
@vito
vito deleted the idable-refactor branch October 12, 2023 18:27
@helderco helderco mentioned this pull request Oct 16, 2023
@gerhard gerhard added this to the v0.9.0 milestone Oct 20, 2023
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
* implement new conventions for IDable objects

This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/rust: remove CacheVolumeID special-case, regen

Signed-off-by: Alex Suraci <[email protected]>

* regen node, python

Signed-off-by: Alex Suraci <[email protected]>

* python: remove noqa now that deprecations are back

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: refactor away high-maintenance type maps

* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>

* re-bootstrap go sdk

Signed-off-by: Alex Suraci <[email protected]>

* add changie

Signed-off-by: Alex Suraci <[email protected]>

* fix up deprecation syntax + typeDef doc

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* add missing doc + regen

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Christian Schlatter <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
* implement new conventions for IDable objects

This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/rust: remove CacheVolumeID special-case, regen

Signed-off-by: Alex Suraci <[email protected]>

* regen node, python

Signed-off-by: Alex Suraci <[email protected]>

* python: remove noqa now that deprecations are back

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: refactor away high-maintenance type maps

* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>

* re-bootstrap go sdk

Signed-off-by: Alex Suraci <[email protected]>

* add changie

Signed-off-by: Alex Suraci <[email protected]>

* fix up deprecation syntax + typeDef doc

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* add missing doc + regen

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
* implement new conventions for IDable objects

This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/rust: remove CacheVolumeID special-case, regen

Signed-off-by: Alex Suraci <[email protected]>

* regen node, python

Signed-off-by: Alex Suraci <[email protected]>

* python: remove noqa now that deprecations are back

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: refactor away high-maintenance type maps

* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>

* re-bootstrap go sdk

Signed-off-by: Alex Suraci <[email protected]>

* add changie

Signed-off-by: Alex Suraci <[email protected]>

* fix up deprecation syntax + typeDef doc

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* add missing doc + regen

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
* implement new conventions for IDable objects

This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/rust: remove CacheVolumeID special-case, regen

Signed-off-by: Alex Suraci <[email protected]>

* regen node, python

Signed-off-by: Alex Suraci <[email protected]>

* python: remove noqa now that deprecations are back

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: refactor away high-maintenance type maps

* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>

* re-bootstrap go sdk

Signed-off-by: Alex Suraci <[email protected]>

* add changie

Signed-off-by: Alex Suraci <[email protected]>

* fix up deprecation syntax + typeDef doc

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* add missing doc + regen

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
schlapzz pushed a commit to schlapzz/dagger that referenced this pull request Nov 24, 2023
* implement new conventions for IDable objects

This is an assorted set of sweeping changes that fix the longstanding
bug involved with traversing lists of ID-able objects in the SDK. We've
worked around this issue about 10 times in the past two weeks, and now I
understand why!

In short, we need a reliable way to go from foos: [Foo!]!, to selecting
the Nth Foo, and querying against it.

In Go this looks like the following, which actually panics prior to
this commit:

    funs, _ := mod.Functions(ctx)
    for _, fun := range funs {
      fun.Name(ctx) // BOOM
    }

This was panicking because the implementation for returning lists of
objects only dealt with scalars, leaving the rest of the object "hollow"
(nil q or c fields). It could have populated c, but q was impossible:
how do you chain queries from the Nth element in a list? If you had a
list of ID-able objects you could at least query them by ID and chain
from there, but how do you know how to query by ID?

This commit adds a new rule: all ID-able objects implement a top-level
`loadFooFromID(id: FooID!): Foo!` resolver. That means when an SDK sees
a list of [Foo!]! objects, it knows it can just fetch IDs and then
create objects that query from loadFooFromID(id: $id).

This new rule is leveraged by a new `core/schema/` helper for
registering resolvers that follow this pattern, to help cut down on a
ton of boilerplate. (I think more code can be deleted than what's in
this commit, may look after.)

Now that there's a dedicated constructor for this, we can start removing
the optional ID arg from other constructors, which also means that
ID-able objects can now be constructed with required args. I applied
this change to GeneratedCode, Module, and Function, and deprecated the
id args everywhere else.

Along the way, I had to rename CacheID to CacheVolumeID. This has long
been a thorn in every SDK developer's side, since it's the _only ID
type_ that doesn't match its corresponding object type. We're about to
make breaking changes for Services v2 so I figure this is worth doing
now.

Also, bumps graphql-go-tools to a version that doesn't just swallow
schema errors and result in cryptic second-order runtime errors.

Signed-off-by: Alex Suraci <[email protected]>

* sdk/rust: remove CacheVolumeID special-case, regen

Signed-off-by: Alex Suraci <[email protected]>

* regen node, python

Signed-off-by: Alex Suraci <[email protected]>

* python: remove noqa now that deprecations are back

Signed-off-by: Alex Suraci <[email protected]>

* sdk/go: refactor away high-maintenance type maps

* One was of all custom scalars (IDs + Platform + JSON) and was
  ultimately used to detect enums during marshaling. This is now handled
  using an interface instead that all enum values conform to.
* The other was, and had to be, only IDs. This was used for detecting if
  FooID! types should be converted to object counterparts. Now we just
  rely on type names always being Type+"ID", which we can do now that
  they're all consistent.

Signed-off-by: Alex Suraci <[email protected]>

* re-bootstrap go sdk

Signed-off-by: Alex Suraci <[email protected]>

* add changie

Signed-off-by: Alex Suraci <[email protected]>

* fix up deprecation syntax + typeDef doc

Signed-off-by: Alex Suraci <[email protected]>

* regen SDKs

Signed-off-by: Alex Suraci <[email protected]>

* add missing doc + regen

Signed-off-by: Alex Suraci <[email protected]>

---------

Signed-off-by: Alex Suraci <[email protected]>
helderco added a commit to helderco/dagger that referenced this pull request Dec 4, 2023
Follow-up to dagger#5881, this is a refactor to simplify converting an ID scalar to object based on the new convention.

Signed-off-by: Helder Correia <[email protected]>
helderco added a commit that referenced this pull request Dec 4, 2023
Follow-up to #5881, this is a refactor to simplify converting an ID scalar to object based on the new convention.

Signed-off-by: Helder Correia <[email protected]>
@helderco helderco mentioned this pull request Dec 6, 2023
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/breaking Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants