diff --git a/CHANGELOG.md b/CHANGELOG.md index c0487c24..29230113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - Added local HTTP server to circumvent deep-link limitations. ([#52](https://github.com/expo/orbit/pull/52), [#53](https://github.com/expo/orbit/pull/53), [#54](https://github.com/expo/orbit/pull/54), [#55](https://github.com/expo/orbit/pull/55) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Show dock icon while windows are opened. ([#50](https://github.com/expo/orbit/pull/50) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Added Projects section to the menu bar. ([#46](https://github.com/expo/orbit/pull/46), [#59](https://github.com/expo/orbit/pull/59) by [@gabrieldonadel](https://github.com/gabrieldonadel)) -- Added support for login to Expo. ([#41](https://github.com/expo/orbit/pull/41), [#43](https://github.com/expo/orbit/pull/43), [#44](https://github.com/expo/orbit/pull/44), [#45](https://github.com/expo/orbit/pull/45) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Added support for login to Expo. ([#41](https://github.com/expo/orbit/pull/41), [#43](https://github.com/expo/orbit/pull/43), [#44](https://github.com/expo/orbit/pull/44), [#45](https://github.com/expo/orbit/pull/45), [#62](https://github.com/expo/orbit/pull/62) by [@gabrieldonadel](https://github.com/gabrieldonadel)) ### 🐛 Bug fixes diff --git a/apps/menu-bar/codegen.ts b/apps/menu-bar/codegen.ts index 47c64922..0d0f4d49 100644 --- a/apps/menu-bar/codegen.ts +++ b/apps/menu-bar/codegen.ts @@ -17,6 +17,9 @@ const config: CodegenConfig = { './src/generated/schema.graphql': { plugins: ['schema-ast'], }, + './src/generated/graphql.possibleTypes.json': { + plugins: ['fragment-matcher'], + }, }, }; diff --git a/apps/menu-bar/package.json b/apps/menu-bar/package.json index 4483ea3a..db1dadd2 100644 --- a/apps/menu-bar/package.json +++ b/apps/menu-bar/package.json @@ -31,6 +31,7 @@ "@babel/preset-env": "^7.22.10", "@babel/runtime": "^7.22.11", "@graphql-codegen/cli": "^5.0.0", + "@graphql-codegen/fragment-matcher": "^5.0.0", "@graphql-codegen/schema-ast": "^4.0.0", "@graphql-codegen/typescript-operations": "^4.0.1", "@graphql-codegen/typescript-react-apollo": "^3.3.7", diff --git a/apps/menu-bar/src/api/ApolloClient.tsx b/apps/menu-bar/src/api/ApolloClient.tsx index 37540cc9..406756d2 100644 --- a/apps/menu-bar/src/api/ApolloClient.tsx +++ b/apps/menu-bar/src/api/ApolloClient.tsx @@ -4,14 +4,13 @@ import { FieldFunctionOptions, HttpLink, InMemoryCache, - NormalizedCacheObject, concat, ApolloProvider, } from '@apollo/client'; import { MMKVWrapper, persistCache } from 'apollo3-cache-persist'; -import { useEffect, useState } from 'react'; import Config from './Config'; +import possibleTypesData from '../generated/graphql.possibleTypes.json'; import { storage } from '../modules/Storage'; const httpLink = new HttpLink({ @@ -27,7 +26,9 @@ const mergeBasedOnOffset = (existing: any[], incoming: any[], { args }: FieldFun return merged; }; +const { possibleTypes } = possibleTypesData; const cache = new InMemoryCache({ + possibleTypes, typePolicies: { AppQuery: { keyFields: ['byId', ['id']], @@ -55,69 +56,38 @@ const cache = new InMemoryCache({ }, }); -export const useApolloClient = () => { - const [sessionSecret, setSessionSecret] = useState(storage.getString('sessionSecret')); - const [client, setClient] = useState>(); - - useEffect(() => { - async function init() { - await persistCache({ - cache, - storage: new MMKVWrapper(storage), - key: 'apollo-cache-persist', - }); - - const authMiddlewareLink = new ApolloLink((operation, forward) => { - if (sessionSecret) { - operation.setContext(({ headers = {} }) => ({ - headers: { - ...headers, - 'expo-session': sessionSecret, - }, - })); - } - - return forward(operation); - }); - - setClient( - new ApolloClient({ - link: concat(authMiddlewareLink, httpLink), - cache, - }) - ); - } - - init(); - }, [sessionSecret]); +const authMiddlewareLink = new ApolloLink((operation, forward) => { + const sessionSecret = storage.getString('sessionSecret'); + if (sessionSecret) { + operation.setContext(({ headers = {} }) => ({ + headers: { + ...headers, + 'expo-session': sessionSecret, + }, + })); + } - useEffect(() => { - const listener = storage.addOnValueChangedListener((changedKey) => { - if (changedKey === 'sessionSecret') { - setSessionSecret(storage.getString('sessionSecret')); - } - }); + return forward(operation); +}); - return () => { - listener.remove(); - }; +async function init() { + await persistCache({ + cache, + storage: new MMKVWrapper(storage), + key: 'apollo-cache-persist', }); +} +init(); - return { - client, - }; -}; +export const apolloClient = new ApolloClient({ + link: concat(authMiddlewareLink, httpLink), + cache, +}); export function withApolloProvider

(Component: React.ComponentType

) { return (props: P) => { - const { client } = useApolloClient(); - - if (!client) { - return null; - } - return ( - + ); diff --git a/apps/menu-bar/src/generated/graphql.possibleTypes.json b/apps/menu-bar/src/generated/graphql.possibleTypes.json new file mode 100644 index 00000000..ad2e10a3 --- /dev/null +++ b/apps/menu-bar/src/generated/graphql.possibleTypes.json @@ -0,0 +1,47 @@ +{ + "possibleTypes": { + "AccountUsageMetadata": [ + "AccountUsageEASBuildMetadata" + ], + "ActivityTimelineProjectActivity": [ + "Build", + "BuildJob", + "Submission", + "Update" + ], + "Actor": [ + "Robot", + "SSOUser", + "User" + ], + "BuildOrBuildJob": [ + "Build", + "BuildJob" + ], + "EASBuildOrClassicBuildJob": [ + "Build", + "BuildJob" + ], + "FcmSnippet": [ + "FcmSnippetLegacy", + "FcmSnippetV1" + ], + "NotificationMetadata": [ + "BuildLimitThresholdExceededMetadata", + "BuildPlanCreditThresholdExceededMetadata", + "TestNotificationMetadata" + ], + "PlanEnablement": [ + "Concurrencies", + "EASTotalPlanEnablement" + ], + "Project": [ + "App", + "Snack" + ], + "UserActor": [ + "SSOUser", + "User" + ] + } +} \ No newline at end of file diff --git a/apps/menu-bar/src/generated/graphql.tsx b/apps/menu-bar/src/generated/graphql.tsx index bbcea453..88566373 100644 --- a/apps/menu-bar/src/generated/graphql.tsx +++ b/apps/menu-bar/src/generated/graphql.tsx @@ -2177,6 +2177,7 @@ export enum BuildCredentialsSource { export type BuildError = { __typename?: 'BuildError'; + buildPhase?: Maybe; docsUrl?: Maybe; errorCode: Scalars['String']['output']; message: Scalars['String']['output']; @@ -2431,6 +2432,50 @@ export type BuildParamsInput = { sdkVersion?: InputMaybe; }; +export enum BuildPhase { + BuilderInfo = 'BUILDER_INFO', + CleanUpCredentials = 'CLEAN_UP_CREDENTIALS', + CompleteBuild = 'COMPLETE_BUILD', + ConfigureExpoUpdates = 'CONFIGURE_EXPO_UPDATES', + ConfigureXcodeProject = 'CONFIGURE_XCODE_PROJECT', + Custom = 'CUSTOM', + DownloadApplicationArchive = 'DOWNLOAD_APPLICATION_ARCHIVE', + EasBuildInternal = 'EAS_BUILD_INTERNAL', + FailBuild = 'FAIL_BUILD', + FixGradlew = 'FIX_GRADLEW', + InstallCustomTools = 'INSTALL_CUSTOM_TOOLS', + InstallDependencies = 'INSTALL_DEPENDENCIES', + InstallPods = 'INSTALL_PODS', + OnBuildCancelHook = 'ON_BUILD_CANCEL_HOOK', + OnBuildCompleteHook = 'ON_BUILD_COMPLETE_HOOK', + OnBuildErrorHook = 'ON_BUILD_ERROR_HOOK', + OnBuildSuccessHook = 'ON_BUILD_SUCCESS_HOOK', + ParseCustomWorkflowConfig = 'PARSE_CUSTOM_WORKFLOW_CONFIG', + PostInstallHook = 'POST_INSTALL_HOOK', + Prebuild = 'PREBUILD', + PrepareArtifacts = 'PREPARE_ARTIFACTS', + PrepareCredentials = 'PREPARE_CREDENTIALS', + PrepareProject = 'PREPARE_PROJECT', + PreInstallHook = 'PRE_INSTALL_HOOK', + PreUploadArtifactsHook = 'PRE_UPLOAD_ARTIFACTS_HOOK', + Queue = 'QUEUE', + ReadAppConfig = 'READ_APP_CONFIG', + ReadPackageJson = 'READ_PACKAGE_JSON', + RestoreCache = 'RESTORE_CACHE', + RunExpoDoctor = 'RUN_EXPO_DOCTOR', + RunFastlane = 'RUN_FASTLANE', + RunGradlew = 'RUN_GRADLEW', + SaveCache = 'SAVE_CACHE', + SetUpBuildEnvironment = 'SET_UP_BUILD_ENVIRONMENT', + SpinUpBuilder = 'SPIN_UP_BUILDER', + StartBuild = 'START_BUILD', + Unknown = 'UNKNOWN', + UploadApplicationArchive = 'UPLOAD_APPLICATION_ARCHIVE', + /** @deprecated No longer supported */ + UploadArtifacts = 'UPLOAD_ARTIFACTS', + UploadBuildArtifacts = 'UPLOAD_BUILD_ARTIFACTS' +} + export type BuildPlanCreditThresholdExceededMetadata = { __typename?: 'BuildPlanCreditThresholdExceededMetadata'; account: Account; @@ -5835,7 +5880,7 @@ export type AppForPinnedListFragment = { __typename?: 'App', id: string, name: s export type GetAppsForPinnedListQueryVariables = Exact<{ [key: string]: never; }>; -export type GetAppsForPinnedListQuery = { __typename?: 'RootQuery', viewer?: { __typename?: 'User', pinnedApps: Array<{ __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } }>, accounts: Array<{ __typename?: 'Account', id: string, appsPaginated: { __typename?: 'AccountAppsConnection', edges: Array<{ __typename?: 'AccountAppsEdge', cursor: string, node: { __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } } }> } }> } | null }; +export type GetAppsForPinnedListQuery = { __typename?: 'RootQuery', meUserActor?: { __typename?: 'SSOUser', id: string, pinnedApps: Array<{ __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } }>, accounts: Array<{ __typename?: 'Account', id: string, appsPaginated: { __typename?: 'AccountAppsConnection', edges: Array<{ __typename?: 'AccountAppsEdge', cursor: string, node: { __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } } }> } }> } | { __typename?: 'User', id: string, pinnedApps: Array<{ __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } }>, accounts: Array<{ __typename?: 'Account', id: string, appsPaginated: { __typename?: 'AccountAppsConnection', edges: Array<{ __typename?: 'AccountAppsEdge', cursor: string, node: { __typename?: 'App', id: string, name: string, slug: string, latestActivity: any, icon?: { __typename?: 'AppIcon', url: string, primaryColor?: string | null } | null, ownerAccount: { __typename?: 'Account', name: string } } }> } }> } | null }; export const AppForPinnedListFragmentDoc = gql` fragment AppForPinnedList on App { @@ -5854,7 +5899,8 @@ export const AppForPinnedListFragmentDoc = gql` `; export const GetAppsForPinnedListDocument = gql` query GetAppsForPinnedList { - viewer { + meUserActor { + id pinnedApps { ...AppForPinnedList } diff --git a/apps/menu-bar/src/generated/schema.graphql b/apps/menu-bar/src/generated/schema.graphql index 03a32eae..b0b1af80 100644 --- a/apps/menu-bar/src/generated/schema.graphql +++ b/apps/menu-bar/src/generated/schema.graphql @@ -1428,6 +1428,7 @@ enum BuildCredentialsSource { } type BuildError { + buildPhase: BuildPhase docsUrl: String errorCode: String! message: String! @@ -1615,6 +1616,49 @@ input BuildParamsInput { sdkVersion: String } +enum BuildPhase { + BUILDER_INFO + CLEAN_UP_CREDENTIALS + COMPLETE_BUILD + CONFIGURE_EXPO_UPDATES + CONFIGURE_XCODE_PROJECT + CUSTOM + DOWNLOAD_APPLICATION_ARCHIVE + EAS_BUILD_INTERNAL + FAIL_BUILD + FIX_GRADLEW + INSTALL_CUSTOM_TOOLS + INSTALL_DEPENDENCIES + INSTALL_PODS + ON_BUILD_CANCEL_HOOK + ON_BUILD_COMPLETE_HOOK + ON_BUILD_ERROR_HOOK + ON_BUILD_SUCCESS_HOOK + PARSE_CUSTOM_WORKFLOW_CONFIG + POST_INSTALL_HOOK + PREBUILD + PREPARE_ARTIFACTS + PREPARE_CREDENTIALS + PREPARE_PROJECT + PRE_INSTALL_HOOK + PRE_UPLOAD_ARTIFACTS_HOOK + QUEUE + READ_APP_CONFIG + READ_PACKAGE_JSON + RESTORE_CACHE + RUN_EXPO_DOCTOR + RUN_FASTLANE + RUN_GRADLEW + SAVE_CACHE + SET_UP_BUILD_ENVIRONMENT + SPIN_UP_BUILDER + START_BUILD + UNKNOWN + UPLOAD_APPLICATION_ARCHIVE + UPLOAD_ARTIFACTS @deprecated + UPLOAD_BUILD_ARTIFACTS +} + type BuildPlanCreditThresholdExceededMetadata { account: Account! buildCreditUsage: Int! diff --git a/apps/menu-bar/src/graphql/apps.gql b/apps/menu-bar/src/graphql/apps.gql index fbbc2c80..d256b6d4 100644 --- a/apps/menu-bar/src/graphql/apps.gql +++ b/apps/menu-bar/src/graphql/apps.gql @@ -13,7 +13,8 @@ fragment AppForPinnedList on App { } query GetAppsForPinnedList { - viewer { + meUserActor { + id pinnedApps { ...AppForPinnedList } diff --git a/apps/menu-bar/src/hooks/useGetPinnedApps.ts b/apps/menu-bar/src/hooks/useGetPinnedApps.ts index e3a1e543..2be14a6a 100644 --- a/apps/menu-bar/src/hooks/useGetPinnedApps.ts +++ b/apps/menu-bar/src/hooks/useGetPinnedApps.ts @@ -13,8 +13,8 @@ export const useGetPinnedApps = () => { fetchPolicy: 'cache-and-network', }); - const pinnedApps = data?.viewer?.pinnedApps; - const accounts = data?.viewer?.accounts; + const pinnedApps = data?.meUserActor?.pinnedApps; + const accounts = data?.meUserActor?.accounts; const apps = useMemo(() => { let apps: PinnedApp[] = []; diff --git a/yarn.lock b/yarn.lock index e91bf816..89cb217b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1398,6 +1398,14 @@ "@graphql-tools/utils" "^10.0.0" tslib "~2.5.0" +"@graphql-codegen/fragment-matcher@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@graphql-codegen/fragment-matcher/-/fragment-matcher-5.0.0.tgz#2a016715e42e8f21aa08830f34a4d0a930e660fe" + integrity sha512-mbash9E8eY6RSMSNrrO+C9JJEn8rdr8ORaxMpgdWL2qe2q/TlLUCE3ZvQvHkSc7GjBnMEk36LncA8ApwHR2BHg== + dependencies: + "@graphql-codegen/plugin-helpers" "^5.0.0" + tslib "~2.5.0" + "@graphql-codegen/plugin-helpers@^2.7.2": version "2.7.2" resolved "https://registry.yarnpkg.com/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.7.2.tgz#6544f739d725441c826a8af6a49519f588ff9bed"