github apollographql/apollo-ios 1.0.0-alpha.1
1.0.0 Alpha 1

latest releases: 1.15.2, 1.15.1, 1.15.0...
pre-release2 years ago

This is the first Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.

What’s New

  • The size of generated code has been reduced dramatically. In the most complex operations, the generated code can be up to 90% smaller than in the previous version.
  • Generated response objects are more powerful and easier to consume.
    • The response objects now intelligently merge fields from not only their parents, but also other matching sibling fragments.
query AnimalQuery {
  allAnimals {
    species
    ... on Pet {
      name
    }
    ... on Cat {
      furColor
    }
}

In the past, the AsCat model would have fields for species, and furColor, but to access the name field, you would need to keep a reference to the AllAnimal object and call AsPet.name. This means that you couldn’t just pass the AsCat object to a UI component.

In 1.0, because we know that Cat implements the Pet interface, the name field is merged into the Cat object.

Any property that should exist based on the type of the object will be accessible. This makes consuming our generated response objects in your applications much easier. This should greatly reduce the need for view models to wrap our generated response objects.

  • The code generation engine is now written in native Swift! This makes it easier for Swift developers to contribute to the project or alter the generated code for their specific needs! In future iterations, we hope to open up the code generation templating API to allow for even easier customization of your generated code!
  • Computation of Cache Keys is protocol oriented now. Instead of a single cacheKeyForObject closure on your ApolloClient, you can implement cache key computation on individual object types with the CacheKeyProvider protocol. See Cache Key Resolution in the RFC for more information.

What’s Next - (Things Not Supported in Alpha 1)

  • Operation Variables and Field Arguments
  • @include/@Skip Directives
  • Cocoapods and Carthage Support for Generated Objects
    • Currently, the generated code supports creating an SPM package you can include as a target in your Package.swift file. Cocoapods and Carthage support will be coming soon.
    • In the mean time, you can still generate your operations and manually include the generated code in your project.
  • Automatically Persisted Queries
  • Cache Mutations
    • We are re-writing the entire cache mutation system to be easier to work with. Instead of exposing the cache via the operations you have defined, you’ll be able to access the cache through custom generated types that have a view of the entire cache at once. *This means no more writing query operations that are only used for local cache mutations.

Feedback we are looking for

While any and all feedback about the API design, structure, and usability of the library is appreciated, this Alpha version version focuses on the new generated operation models. We would love to hear about your experiences with:

  • Generating your models using the SwiftScripts method
  • Consuming the new generated models in your application code
    • Are there any use cases that were supported in the previous versions that are not supported or regress in the Alpha? (Other than the known cases listed above that will be supported soon.)
    • Do the new generated models make working with your data easier or more difficult?
    • Do you have specific suggestions for things that can be added or altered in the generated objects to make them more useful?

Expected Alpha Roadmap

  • Operation Variables and Field Arguments
    • ASAP - Planned for next Alpha release within a week or two.
  • @include/@Skip Directives
    • Next priority after variables and arguments. Maybe the same release, maybe the next release after that
  • Cocoapods and Carthage Support for Generated Objects
    • Probably a little while out, but shouldn’t be too hard. So maybe after the two above this.
  • Automatically Persisted Queries
    • This is mostly done, just need to actually figure out how to compute the operation identifier hash and generate the operationIds.json file. This is lower priority though, since not a ton of people use it.
  • Cache Mutations
    • This is going to take a long time still. We won’t move into Beta until we have the solution for this ready to test, but it’s only about 70% solved so far, and the implementation is not written yet.
    • I’m considering exposing an API to mutate the cache just using the stringly-typed dictionary of data in the mean time, to unblock people from trying out the Alpha in their applications while we solve this. This would be unsafe and not great for production, but should work just fine and be quick and easy to implement as a stop-gap.

Installation

Currently, only SPM is fully supported. Because the generated models can’t easily be consumed by a Cocoapods project yet, we have not included support for installation of the client with Cocoapods. This will be included in an upcoming release shortly.

SPM

.package(name: "Apollo",
         url: "https://github.com/apollographql/apollo-ios.git", 
         from: "1.0.0-alpha.1")

Run codegen using the instructions from the Swift scripting documentation.

Don't miss a new apollo-ios release

NewReleases is sending notifications on new releases.