Skip to content

Commit 1614238

Browse files
committed
Use generated types in embedded update mutations
1 parent 67f4b6c commit 1614238

2 files changed

Lines changed: 14 additions & 24 deletions

File tree

packages/eas-cli/src/graphql/mutations/EmbeddedUpdateAssetMutation.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import gql from 'graphql-tag';
22

33
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
4+
import {
5+
GetSignedEmbeddedUpdateAssetUploadSpecMutation,
6+
GetSignedEmbeddedUpdateAssetUploadSpecMutationVariables,
7+
} from '../generated';
48
import { withErrorHandlingAsync } from '../client';
59

10+
// fields is typed as `any` (JSONObject scalar) in the generated type; we keep a
11+
// more specific type here so callers don't have to cast.
612
export type EmbeddedUpdateAssetUploadSpec = {
713
storageKey: string;
814
presignedUrl: string;
915
fields: Record<string, string>;
1016
};
1117

12-
type GetSignedEmbeddedUploadSpecMutationResult = {
13-
embeddedUpdateAsset: {
14-
getSignedEmbeddedUpdateAssetUploadSpecifications: EmbeddedUpdateAssetUploadSpec;
15-
};
16-
};
17-
1818
export const EmbeddedUpdateAssetMutation = {
1919
async getSignedUploadSpecAsync(
2020
graphqlClient: ExpoGraphqlClient,
@@ -26,7 +26,7 @@ export const EmbeddedUpdateAssetMutation = {
2626
): Promise<EmbeddedUpdateAssetUploadSpec> {
2727
const data = await withErrorHandlingAsync(
2828
graphqlClient
29-
.mutation<GetSignedEmbeddedUploadSpecMutationResult>(
29+
.mutation<GetSignedEmbeddedUpdateAssetUploadSpecMutation, GetSignedEmbeddedUpdateAssetUploadSpecMutationVariables>(
3030
gql`
3131
mutation GetSignedEmbeddedUpdateAssetUploadSpec(
3232
$appId: ID!

packages/eas-cli/src/graphql/mutations/EmbeddedUpdateMutation.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { CombinedError } from '@urql/core';
22
import gql from 'graphql-tag';
33

44
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
5-
import { AppPlatform } from '../generated';
5+
import {
6+
AppPlatform,
7+
UploadEmbeddedUpdateInput,
8+
UploadEmbeddedUpdateMutation,
9+
UploadEmbeddedUpdateMutationVariables,
10+
} from '../generated';
611
import { withErrorHandlingAsync } from '../client';
712

813
export type EmbeddedUpdateResult = {
@@ -13,21 +18,6 @@ export type EmbeddedUpdateResult = {
1318
createdAt: string;
1419
};
1520

16-
type UploadEmbeddedUpdateInput = {
17-
appId: string;
18-
platform: AppPlatform;
19-
runtimeVersion: string;
20-
channel: string;
21-
embeddedUpdateId: string;
22-
turtleBuildId?: string;
23-
};
24-
25-
type UploadEmbeddedUpdateMutationResult = {
26-
embeddedUpdate: {
27-
uploadEmbeddedUpdate: EmbeddedUpdateResult;
28-
};
29-
};
30-
3121
export function isEmbeddedUpdateAssetNotAvailableError(error: unknown): boolean {
3222
return (
3323
error instanceof CombinedError &&
@@ -44,7 +34,7 @@ export const EmbeddedUpdateMutation = {
4434
): Promise<EmbeddedUpdateResult> {
4535
const data = await withErrorHandlingAsync(
4636
graphqlClient
47-
.mutation<UploadEmbeddedUpdateMutationResult>(
37+
.mutation<UploadEmbeddedUpdateMutation, UploadEmbeddedUpdateMutationVariables>(
4838
gql`
4939
mutation UploadEmbeddedUpdate($input: UploadEmbeddedUpdateInput!) {
5040
embeddedUpdate {

0 commit comments

Comments
 (0)