Compare commits

..
Author SHA1 Message Date
Quinlan Jung 14d491a558 [eas-cli] unify channel graphql query types 2023-07-24 15:54:43 -07:00
7 changed files with 52 additions and 52 deletions

No files matched your search

+2 -4
View File
@@ -1,5 +1,4 @@
import chalk from 'chalk';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
@@ -13,7 +12,6 @@ import {
} from '../graphql/generated';
import { BranchQuery, UpdateBranchOnChannelObject } from '../graphql/queries/BranchQuery';
import { ChannelQuery, UpdateChannelObject } from '../graphql/queries/ChannelQuery';
import { UpdateChannelBasicInfoFragmentNode } from '../graphql/types/UpdateChannelBasicInfo';
import Log from '../log';
import formatFields from '../utils/formatFields';
import { printJsonOnlyOutput } from '../utils/json';
@@ -229,11 +227,11 @@ export async function createChannelOnAppAsync(
updateChannel {
createUpdateChannelForApp(appId: $appId, name: $name, branchMapping: $branchMapping) {
id
...UpdateChannelBasicInfoFragment
name
branchMapping
}
}
}
${print(UpdateChannelBasicInfoFragmentNode)}
`,
{
appId,
+23 -1
View File
@@ -1,7 +1,7 @@
import assert from 'assert';
import chalk from 'chalk';
import { UpdateChannelObject } from '../graphql/queries/ChannelQuery';
import { UpdateBranchObject, UpdateChannelObject } from '../graphql/queries/ChannelQuery';
import Log from '../log';
import {
FormattedBranchDescription,
@@ -109,3 +109,25 @@ export function logChannelDetails(channel: UpdateChannelObject): void {
);
}
}
function getUpdateBranchNullable(
channel: UpdateChannelObject,
branchId: string
): UpdateBranchObject | null {
const updateBranches = channel.updateBranches;
const updateBranch = updateBranches.find(branch => branch.id === branchId);
return updateBranch ?? null;
}
export function getUpdateBranch(
channel: UpdateChannelObject,
branchId: string
): UpdateBranchObject {
const updateBranch = getUpdateBranchNullable(channel, branchId);
if (!updateBranch) {
throw new Error(
`Could not find branch with id "${branchId}" in branch-mapping of channel "${channel.name}"`
);
}
return updateBranch;
}
@@ -1,6 +1,5 @@
import { Flags } from '@oclif/core';
import chalk from 'chalk';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { selectBranchOnAppAsync } from '../../branch/queries';
@@ -10,20 +9,18 @@ import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/creat
import { EasNonInteractiveAndJsonFlags } from '../../commandUtils/flags';
import { withErrorHandlingAsync } from '../../graphql/client';
import {
UpdateChannelBasicInfoFragment,
UpdateChannelBranchMappingMutation,
UpdateChannelBranchMappingMutationVariables,
} from '../../graphql/generated';
import { BranchQuery } from '../../graphql/queries/BranchQuery';
import { ChannelQuery } from '../../graphql/queries/ChannelQuery';
import { UpdateChannelBasicInfoFragmentNode } from '../../graphql/types/UpdateChannelBasicInfo';
import { ChannelQuery, UpdateChannelBasicInfo } from '../../graphql/queries/ChannelQuery';
import Log from '../../log';
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
export async function updateChannelBranchMappingAsync(
graphqlClient: ExpoGraphqlClient,
{ channelId, branchMapping }: UpdateChannelBranchMappingMutationVariables
): Promise<UpdateChannelBasicInfoFragment> {
): Promise<UpdateChannelBasicInfo> {
const data = await withErrorHandlingAsync(
graphqlClient
.mutation<UpdateChannelBranchMappingMutation, UpdateChannelBranchMappingMutationVariables>(
@@ -32,11 +29,11 @@ export async function updateChannelBranchMappingAsync(
updateChannel {
editUpdateChannel(channelId: $channelId, branchMapping: $branchMapping) {
id
...UpdateChannelBasicInfoFragment
name
branchMapping
}
}
}
${print(UpdateChannelBasicInfoFragmentNode)}
`,
{ channelId, branchMapping }
)
-4
View File
@@ -6308,10 +6308,6 @@ export type UpdateFragment = { __typename?: 'Update', id: string, group: string,
export type UpdateBranchFragment = { __typename?: 'UpdateBranch', id: string, name: string, updates: Array<{ __typename?: 'Update', id: string, group: string, message?: string | null, createdAt: any, runtimeVersion: string, platform: string, manifestFragment: string, isRollBackToEmbedded: boolean, manifestPermalink: string, gitCommitHash?: string | null, actor?: { __typename: 'Robot', firstName?: string | null, id: string } | { __typename: 'SSOUser', username: string, id: string } | { __typename: 'User', username: string, id: string } | null, branch: { __typename?: 'UpdateBranch', id: string, name: string }, codeSigningInfo?: { __typename?: 'CodeSigningInfo', keyid: string, sig: string, alg: string } | null }> };
export type UpdateBranchWithCurrentGroupFragment = { __typename?: 'UpdateBranch', id: string, name: string, updateGroups: Array<Array<{ __typename?: 'Update', id: string, group: string, message?: string | null, createdAt: any, runtimeVersion: string, platform: string, manifestFragment: string, isRollBackToEmbedded: boolean, manifestPermalink: string, gitCommitHash?: string | null, actor?: { __typename: 'Robot', firstName?: string | null, id: string } | { __typename: 'SSOUser', username: string, id: string } | { __typename: 'User', username: string, id: string } | null, branch: { __typename?: 'UpdateBranch', id: string, name: string }, codeSigningInfo?: { __typename?: 'CodeSigningInfo', keyid: string, sig: string, alg: string } | null }>> };
export type UpdateChannelBasicInfoFragment = { __typename?: 'UpdateChannel', id: string, name: string, branchMapping: string };
export type WebhookFragment = { __typename?: 'Webhook', id: string, event: WebhookType, url: string, createdAt: any, updatedAt: any };
export type AndroidAppBuildCredentialsFragment = { __typename?: 'AndroidAppBuildCredentials', id: string, isDefault: boolean, isLegacy: boolean, name: string, androidKeystore?: { __typename?: 'AndroidKeystore', id: string, type: AndroidKeystoreType, keystore: string, keystorePassword: string, keyAlias: string, keyPassword?: string | null, md5CertificateFingerprint?: string | null, sha1CertificateFingerprint?: string | null, sha256CertificateFingerprint?: string | null, createdAt: any, updatedAt: any } | null };
@@ -6,7 +6,6 @@ import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/creat
import { withErrorHandlingAsync } from '../client';
import {
PageInfo,
UpdateChannelBasicInfoFragment,
ViewUpdateChannelOnAppQuery,
ViewUpdateChannelOnAppQueryVariables,
ViewUpdateChannelsOnAppQuery,
@@ -14,8 +13,7 @@ import {
ViewUpdateChannelsPaginatedOnAppQuery,
ViewUpdateChannelsPaginatedOnAppQueryVariables,
} from '../generated';
import { UpdateBranchWithCurrentGroupFragmentNode } from '../types/UpdateBranchWithCurrentUpdate';
import { UpdateChannelBasicInfoFragmentNode } from '../types/UpdateChannelBasicInfo';
import { UpdateFragmentNode } from '../types/Update';
type ViewUpdateChannelsOnAppObject = NonNullable<
ViewUpdateChannelsOnAppQuery['app']['byId']['updateChannels']
@@ -25,9 +23,15 @@ type UpdateChannelByNameObject = NonNullable<
ViewUpdateChannelOnAppQuery['app']['byId']['updateChannelByName']
>;
// these types should have the same fields
// this asserts they are the same thing
export type UpdateChannelObject = ViewUpdateChannelsOnAppObject & UpdateChannelByNameObject;
export type UpdateBranchObject = UpdateChannelObject['updateBranches'][number];
export type UpdateChannelBasicInfo = NonNullable<
ViewUpdateChannelsPaginatedOnAppQuery['app']['byId']['channelsPaginated']['edges'][0]['node']
>;
export const ChannelQuery = {
async viewUpdateChannelAsync(
graphqlClient: ExpoGraphqlClient,
@@ -48,13 +52,17 @@ export const ChannelQuery = {
branchMapping
updateBranches(offset: 0, limit: 5) {
id
...UpdateBranchWithCurrentGroupFragment
name
updateGroups(offset: 0, limit: 1) {
id
...UpdateFragment
}
}
}
}
}
}
${print(UpdateBranchWithCurrentGroupFragmentNode)}
${print(UpdateFragmentNode)}
`,
{ appId, channelName },
{ additionalTypenames: ['UpdateChannel', 'UpdateBranch', 'Update'] }
@@ -88,13 +96,17 @@ export const ChannelQuery = {
branchMapping
updateBranches(offset: 0, limit: 5) {
id
...UpdateBranchWithCurrentGroupFragment
name
updateGroups(offset: 0, limit: 1) {
id
...UpdateFragment
}
}
}
}
}
}
${print(UpdateBranchWithCurrentGroupFragmentNode)}
${print(UpdateFragmentNode)}
`,
{ appId, offset, limit },
{ additionalTypenames: ['UpdateChannel', 'UpdateBranch', 'Update'] }
@@ -112,7 +124,7 @@ export const ChannelQuery = {
async viewUpdateChannelsBasicInfoPaginatedOnAppAsync(
graphqlClient: ExpoGraphqlClient,
{ appId, first, after }: ViewUpdateChannelsPaginatedOnAppQueryVariables
): Promise<[UpdateChannelBasicInfoFragment[], PageInfo]> {
): Promise<[UpdateChannelBasicInfo[], PageInfo]> {
const response = await withErrorHandlingAsync(
graphqlClient
.query<
@@ -128,7 +140,8 @@ export const ChannelQuery = {
edges {
node {
id
...UpdateChannelBasicInfoFragment
name
branchMapping
}
}
pageInfo {
@@ -141,7 +154,6 @@ export const ChannelQuery = {
}
}
}
${print(UpdateChannelBasicInfoFragmentNode)}
`,
{ appId, first, after },
{ additionalTypenames: ['UpdateChannel', 'UpdateBranch', 'Update'] }
@@ -1,16 +0,0 @@
import { print } from 'graphql';
import gql from 'graphql-tag';
import { UpdateFragmentNode } from './Update';
export const UpdateBranchWithCurrentGroupFragmentNode = gql`
fragment UpdateBranchWithCurrentGroupFragment on UpdateBranch {
id
name
updateGroups(offset: 0, limit: 1) {
id
...UpdateFragment
}
}
${print(UpdateFragmentNode)}
`;
@@ -1,9 +0,0 @@
import gql from 'graphql-tag';
export const UpdateChannelBasicInfoFragmentNode = gql`
fragment UpdateChannelBasicInfoFragment on UpdateChannel {
id
name
branchMapping
}
`;