Swiftpack.co - apollographql/apollo-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by apollographql.
apollographql/apollo-ios v0.3.0
📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
⭐️ 3,366
🕓 Yesterday
iOS macOS watchOS tvOS
.package(url: "https://github.com/apollographql/apollo-ios.git", from: "v0.3.0")

Apollo GraphQL

CircleCI build status MIT license Supported Platforms: iOS, macOS, tvOS, watchOS

Swift 5 supported Swift Package Manager compatible Carthage compatible CocoaPods compatible

Apollo iOS is a strongly-typed, caching GraphQL client, written in Swift.

It allows you to execute queries and mutations against a GraphQL server, and returns results as query-specific Swift types. This means you don’t have to deal with parsing JSON, or passing around dictionaries and making clients cast values to the right type manually. You also don't have to write model types yourself, because these are generated from the GraphQL definitions your UI uses.

As the generated types are query-specific, you're only able to access data you actually specify as part of a query. If you don't ask for a field, you won't be able to access the corresponding property. In effect, this means you can now rely on the Swift type checker to make sure errors in data access show up at compile time. With our Xcode integration, you can conveniently work with your UI code and corresponding GraphQL definitions side by side, and it will even validate your query documents, and show errors inline.

Apollo iOS does more than simply run your queries against a GraphQL server: It normalizes query results to construct a client-side cache of your data, which is kept up to date as further queries and mutations are run. This means your UI is always internally consistent, and can be kept fully up-to-date with the state on the server with the minimum number of queries required.

This combination of models with value semantics, one way data flow, and automatic consistency management, leads to a very powerful and elegant programming model that allows you to eliminate common glue code and greatly simplifies app development.

Getting started

If you are new to Apollo iOS there are two ways to get started:

  1. The tutorial which will guide you through building an iOS app using Swift and Apollo iOS.
  2. A Playground covering the concepts of queries, mutations, subscriptions, SQLite caching and custom scalars.

There is also comprehensive documentation including an API reference.

Releases and changelog

All releases are catalogued and we maintain a changelog which details all changes to the library.

Roadmap

The roadmap is a high-level document that describes the next major steps or milestones for this project. We are always open to feature requests, and contributions from the community.

Contributing

This project is being developed using Xcode 12.5 and Swift 5.4.

If you open Apollo.xcodeproj, you should be able to run the tests of the Apollo, ApolloSQLite, and ApolloWebSocket frameworks on your Mac or an iOS Simulator.

NOTE: Due to a change in behavior in Xcode 11's git integration, if you check this repo out using Xcode, please close the window Xcode automatically opens using the Swift Package manager structure, and open the Apollo.xcodeproj file instead.

Some of the tests run against a simple GraphQL server serving the Star Wars example schema (see installation instructions there).

If you'd like to contribute, please refer to the Apollo Contributor Guide.

Maintainers

Who is Apollo?

Apollo builds open-source software and a graph platform to unify GraphQL across your apps and services. We help you ship faster with:

  • Apollo Studio – A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. Studio provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
  • Apollo Federation – The industry-standard open architecture for building a distributed graph. Use Apollo’s gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
  • Apollo Client – The most popular GraphQL client for the web. Apollo also builds and maintains Apollo iOS and Apollo Android.
  • Apollo Server – A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.

Learn how to build with Apollo

Check out the Odyssey learning platform, the perfect place to start your GraphQL journey with videos and interactive code challenges. Join the Apollo Community to interact with and get technical help from the GraphQL community.

GitHub

link
Stars: 3366
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.0.0 Alpha 7
1 week ago

This is the seventh 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.

  • New: Local Cache Mutations are now supported: In order to perform a local cache mutation, define a .graphql file with an operation or a fragment and mark it with the directive @apollo_client_ios_localCacheMutation. This will ensure the code generator generates a mutable cache mutation operation.
    • Note: Local Cache Mutation operations cannot be used for fetching from the network! You should define separate GraphQL operations for network operations and local cache mutations.
    • Example Usage:
/// SampleLocalCacheMutation.graphql
query SampleLocalCacheMutation @apollo_client_ios_localCacheMutation {
  allAnimals {
    species
    skinCovering
    ... on Bird {
      wingspan
    }
  }
}

/// SampleLocalCacheMutationFragment.graphql
fragment SampleLocalCacheMutationFragment on Pet @apollo_client_ios_localCacheMutation {
  owner {
    firstName
  }
}
  • New: Support Code Generation Configuration Option: deprecatedEnumCases: If deprecatedEnumCases is set to exclude, deprecated cases in graphql enums from your schema will not be generated and will be treated as unknown enum values.
  • Fixed - Compilation Errors in Generated Code When Schema was Embedded In Target: When embedding the generated schema in your own target, rather than generating a separate module for it, there were compilation errors due to access control and namespacing issues. These are resolved. This fixes #2301 & #2302. Thanks @kimdv for calling attention to these bugs!
    • Note: Compilation Errors for Test Mocks are still present. We are aware of ongoing issues with generated test mocks. We are actively working on fixing these issues and they will be resolved in a future alpha release soon.
  • Fixed: Crash When Accessing a Conditionally Included Fragment That is Nil. This is fixed now and will return nil as it should. This fixes #2310.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics