Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apollo Client #378

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Add Apollo Client #378

merged 1 commit into from
Apr 10, 2024

Conversation

vinnie4k
Copy link
Contributor

Overview

Added the Apollo iOS Client to the codebase to integrate with Uplift’s GraphQL backend.

Changes Made

Apollo

  • The Codegen CLI looks at the configuration JSON files (in our secrets) as well as our .graphql files to generate the API.
  • There is a build script that runs the Codegen CLI executable based on the currently selected schema (DEBUG or RELEASE).
  • The Swift code defined inside of UpliftAPI has been configured with the internal access modifier. Because I have configured it to be used directly within the target instead of a library, we will need to prepend UpliftAPI. (with the dot) to access anything generated by Apollo, which is nested inside of an enumeration called UpliftAPI.

Networking

  • Created ApolloNetwork.swift to contain code that accesses the Apollo Client.
  • Created Publishers.swift that extends the Publishers class defined in the Combine framework.
    • This file contains two structs (one for queries, one for mutations) that is used for configuring the publishers used.
    • These configurations are very flexible and have support for optimization with caching, concurrency, etc:
      • cachePolicy: A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache. Defaults to .default.
      • contextIdentifier?: A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to nil.
      • context?: A context that is being passed through the request chain. Defaults to nil.
      • queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
      • publishResultToStore: If true, this will publish the result returned from the operation to the cache store. Defaults to true. For mutations only.
    • This file also defines a class called ApolloMutationSubscription that processes the subscription that is received by the publishers.
  • Created ApolloClientProtocol.swift that extends the ApolloClientProtocol class defined in the Apollo and ApolloAPI libraries.
    • This file contains two functions (one for queries, one for mutations) that returns the Combine publishers defined in Publishers.swift.

Other Changes

  • Updated README.md with the up-to-date instructions for setting up the codebase.
  • Temporarily removed the AppDevAnnouncements package because it is currently being refactored. See added // TODO comments in the codebase.
  • Removed the TCATTest target/testing suite because it is outdated.
  • Removed Siri extension because it is outdated.
  • Updated our secrets/environment variables with Eatery and Uplift’s backend server URL.
    • Note that Transit’s URL now has an https:// prepended. To account for this, the current code removes https:// from the URL. The reason for this change is because we will be refactoring networking in the codebase soon.
  • Reorganized the project directory since there were files that were not properly in their folder on Finder, but were organized correctly in the project.
  • Minor syntax changes to the codebase.

Test Coverage

  • Tested on the simulator and a physical device for mainly UI issues.

Next Steps

  • Since everything works locally in development, I will need to see if Xcode Cloud works with these new changes.
  • Update our Xcode Cloud workflow, Slack channels, and secrets manager with the new secrets and environment variables.
  • Write Uplift models to be used within the codebase.
  • Refactor networking and add AppDev Announcements once they’re ready.

Copy link
Contributor

@daniel-chuang daniel-chuang left a comment

Choose a reason for hiding this comment

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

My goat

@vinnie4k vinnie4k merged commit 6cde730 into master Apr 10, 2024
@vinnie4k vinnie4k deleted the vin/apollo branch April 10, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants