From b4e667e1d62442a038dd51d35b8df1ac7254dd1b Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Sat, 20 Apr 2024 22:26:55 +0700 Subject: [PATCH] chore(sdk/elixir): use introspection json schema from codegen Similar to Python SDK, uses introspection from `t.Dagger.instrospection` to generate schema file and mounting it to the container to generate code. Signed-off-by: Thanabodee Charoenpiriyakij --- ci/sdk_elixir.go | 9 +- .../dagger_codegen/priv/introspection.graphql | 99 ------------------- sdk/elixir/scripts/fetch_introspection.exs | 4 - 3 files changed, 6 insertions(+), 106 deletions(-) delete mode 100644 sdk/elixir/dagger_codegen/priv/introspection.graphql delete mode 100644 sdk/elixir/scripts/fetch_introspection.exs diff --git a/ci/sdk_elixir.go b/ci/sdk_elixir.go index 038abe5352..afb8e88e57 100644 --- a/ci/sdk_elixir.go +++ b/ci/sdk_elixir.go @@ -70,14 +70,17 @@ func (t ElixirSDK) Generate(ctx context.Context) (*Directory, error) { if err != nil { return nil, err } - + introspection, err := t.Dagger.introspection(ctx, installer) + if err != nil { + return nil, err + } gen := t.elixirBase(elixirVersions[0]). With(installer). - WithExec([]string{"mix", "run", "scripts/fetch_introspection.exs"}). WithWorkdir("dagger_codegen"). WithExec([]string{"mix", "deps.get"}). WithExec([]string{"mix", "escript.build"}). - WithExec([]string{"./dagger_codegen", "generate", "--introspection", "../introspection.json", "--outdir", "gen"}). + WithMountedFile("/schema.json", introspection). + WithExec([]string{"./dagger_codegen", "generate", "--introspection", "/schema.json", "--outdir", "gen"}). WithExec([]string{"mix", "format", "gen/*.ex"}). Directory("gen") diff --git a/sdk/elixir/dagger_codegen/priv/introspection.graphql b/sdk/elixir/dagger_codegen/priv/introspection.graphql deleted file mode 100644 index d17da75f35..0000000000 --- a/sdk/elixir/dagger_codegen/priv/introspection.graphql +++ /dev/null @@ -1,99 +0,0 @@ -query IntrospectionQuery { - __schema { - queryType { - name - } - mutationType { - name - } - subscriptionType { - name - } - types { - ...FullType - } - directives { - name - description - locations - args { - ...InputValue - } - } - } -} - -fragment FullType on __Type { - kind - name - description - fields(includeDeprecated: true) { - name - description - args { - ...InputValue - } - type { - ...TypeRef - } - isDeprecated - deprecationReason - } - inputFields { - ...InputValue - } - interfaces { - ...TypeRef - } - enumValues(includeDeprecated: true) { - name - description - isDeprecated - deprecationReason - } - possibleTypes { - ...TypeRef - } -} - -fragment InputValue on __InputValue { - name - description - type { - ...TypeRef - } - defaultValue -} - -fragment TypeRef on __Type { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - } - } - } - } - } - } - } -} diff --git a/sdk/elixir/scripts/fetch_introspection.exs b/sdk/elixir/scripts/fetch_introspection.exs deleted file mode 100644 index d208ce83ff..0000000000 --- a/sdk/elixir/scripts/fetch_introspection.exs +++ /dev/null @@ -1,4 +0,0 @@ -query = File.read!("dagger_codegen/priv/introspection.graphql") -{:ok, client} = Dagger.Core.Client.connect(connect_timeout: :timer.seconds(50)) -{:ok, resp} = Dagger.Core.Client.query(client, query) -File.write!("introspection.json", Jason.encode!(resp["data"]))