📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.

Overview

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 open-source 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.

Comments
  • Unable to run code generation

    Unable to run code generation

    Bug report

    Installing Apollo 1.0.0 via Cocoapods results in code generation error.

    Versions

    Please fill in the versions you're currently using:

    • apollo-ios SDK version: 1.0.0
    • Xcode version: 14.0.1
    • Swift version: 5.7
    • Package manager: N/A
    • Cocoapods version: 1.11.3

    Steps to reproduce

    pod init

    Add pod 'Apollo'

    pod install

    ./Pods/Apollo/apollo-ios-cli init --schema-name MySchema ./Pods/Apollo/apollo-ios-cli generate

    ApolloCodegenLib/resource_bundle_accessor.swift:11: Fatal error: could not load resource bundle: from /Users/xxx/ProjectName/Pods/Apollo/Apollo_ApolloCodegenLib.bundle or /Users/xxx/Library/Caches/CocoaPods/Pods/Release/Apollo/1.0.0-95555/.build/arm64-apple-macosx/release/Apollo_ApolloCodegenLib.bundle
    zsh: trace trap  ./Pods/Apollo/apollo-ios-cli generate
    

    Further details

    Note that cocoapods is installed using Hombrew.

    bug codegen 
    opened by ilockett 63
  • Provide a pattern for dynamic reconfiguration of network transport / auth headers

    Provide a pattern for dynamic reconfiguration of network transport / auth headers

    It's not clear how to use the API to implement login / logout, as it would require us to reconfigure headers. We’ll need a way to dynamically configure / reconfigure the client instance to provide different auth headers, perhaps other transport options as well.

    enhancement 
    opened by timbotnik 55
  • use lock in InMemoryNormalizedCache to avoid race conditions

    use lock in InMemoryNormalizedCache to avoid race conditions

    we see some crashes trying to access RecordSet while doing .clear() on InMemoryNormalizedCache

    * thread #35, queue = 'com.apollographql.DataLoader', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
      frame #0: 0x00000001c71bf530 libobjc.A.dylib`objc_msgSend + 16
      frame #1: 0x00000001f60ee364 libswiftCore.dylib`Swift.Dictionary._Variant.subscript.getter : (A) -> Swift.Optional<B> + 148
      frame #2: 0x0000000106044da8 Apollo`RecordSet.subscript.getter(key="User_12", self=Apollo.RecordSet @ 0x00000001701b20d8) at RecordSet.swift:24:19
      frame #3: 0x000000010602fc64 Apollo`closure #1 in InMemoryNormalizedCache.loadRecords($0="User_12", self=0x0000000282b1ef60) at InMemoryNormalizedCache.swift:9:42
      frame #4: 0x000000010602fce8 Apollo`thunk for @callee_guaranteed (@guaranteed String) -> (@owned Record?, @error @owned Error) at <compiler-generated>:0
      frame #5: 0x000000010602fdcc Apollo`partial apply for thunk for @callee_guaranteed (@guaranteed String) -> (@owned Record?, @error @owned Error) at <compiler-generated>:0
      frame #6: 0x00000001f6074ef4 libswiftCore.dylib`(extension in Swift):Swift.Collection.map<A>((A.Element) throws -> A1) throws -> Swift.Array<A1> + 748
      frame #7: 0x000000010602fb1c Apollo`InMemoryNormalizedCache.loadRecords(keys=1 value, self=0x0000000282b1ef60) at InMemoryNormalizedCache.swift:9:24
      frame #8: 0x0000000106030228 Apollo`protocol witness for NormalizedCache.loadRecords(forKeys:) in conformance InMemoryNormalizedCache at <compiler-generated>:0
      frame #9: 0x0000000106001c20 Apollo`partial apply at <compiler-generated>:0
      frame #10: 0x00000001060099c4 Apollo`closure #1 in DataLoader.dispatch(self=0x00000002831abd00) at DataLoader.swift:53:12
      frame #11: 0x0000000105ff0d50 Apollo`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
      frame #12: 0x00000001084176f0 libdispatch.dylib`_dispatch_call_block_and_release + 24
      frame #13: 0x0000000108418c74 libdispatch.dylib`_dispatch_client_callout + 16
      frame #14: 0x0000000108420bf4 libdispatch.dylib`_dispatch_lane_serial_drain + 712
      frame #15: 0x00000001084218b4 libdispatch.dylib`_dispatch_lane_invoke + 456
      frame #16: 0x000000010842b77c libdispatch.dylib`_dispatch_workloop_worker_thread + 1148
      frame #17: 0x00000001c7bed114 libsystem_pthread.dylib`_pthread_wqthread + 304
      frame #18: 0x00000001c7befcd4 libsystem_pthread.dylib`start_wqthread + 4
    

    sentry.io log Screenshot 2019-07-29 at 13 18 32

    This PR wraps access to InMemoryNormalizedCache.records in internal queue to avoid race conditions.

    opened by RolandasRazma 49
  • Generate Apollo GraphQL API phase not executing properly

    Generate Apollo GraphQL API phase not executing properly

    I am having trouble getting the build phase execute prperly. I have properly created the build script and using default paths for my *.graphql and schema.json. It looks like Xcode is running the generation phase but no API.swift file is generated.

    Any directions on how to debug this?

    Using Apollo 0.3.1 and apollo-codegen 0.8.2

    codegen 
    opened by attheodo 48
  • Mo' Better Uploading

    Mo' Better Uploading

    I started trying to get some real documentation together for uploading and noticed a few holes in the implementation. This PR tries to address what I found.

    In this PR:

    • Fixed an issue where we were setting the default Content-Type late enough that it was hammering the form data upload type which is set when there's form data.
    • Add an UploadingNetworkTransport sub-protocol of NetworkTransport to capture that not all network transports handle uploads.
    • Make HTTPNetworkTransport and SplitNetworkTransport conform to this protocol.
    • Add upload support to the main ApolloClient class so you don't need a direct reference to the network transport anymore. Note that this will hit an assertionFailure during development and return an Error in production if you attempt to use it with a NetworkTransport which does not also conform to UploadingNetworkTransport.
    • Added tests to make sure RequestCreator is properly creating multipart requests.
    • Actually added the documentation I came to add in the first place 🙃
    opened by designatednerd 46
  • Command PhaseScriptExecution failed with a nonzero exit code ( on version 0.13.0)

    Command PhaseScriptExecution failed with a nonzero exit code ( on version 0.13.0)

    Currently I use Apollo 0.11.1 with pod, It works well. After I upgrade to a new version 0.13.0 I got error when build as below:

    Duplicate "graphql" modules cannot be used at the same time since different
    versions may have different capabilities and behavior. The data from one
    version used in the function from another could produce confusing and
    spurious results.
    at instanceOf (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isInputObjectType (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:146:34)
    at isType (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:82:120)
    at isNullableType (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:331:10)
    at assertNullableType (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:335:4)
    at new GraphQLNonNull (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:299:19)
    at GraphQLNonNull (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/type/definition.js:301:12)
    at Object.typeFromAST (~/Desktop/App-iOS/node_modules/apollo/node_modules/graphql/utilities/typeFromAST.js:27:56)
    at ~/Desktop/App-iOS/node_modules/apollo/node_modules/apollo-codegen-core/lib/compiler/index.js:73:36
    at Array.map (<anonymous>)
    
    Command PhaseScriptExecution failed with a nonzero exit code
    
    • This is my current version on system - apollo/2.16.1 darwin-x64 node-v12.1.0 - xcode 10.3

    Until now I didn't solve it yet. so what should I do? Please leave any comment. Thanks

    build-issue 
    opened by sovannarithsok 44
  • Query watcher not being called when cache is updated on an element by another query/subscription/mutation

    Query watcher not being called when cache is updated on an element by another query/subscription/mutation

    Bug report

    Query watcher not being called when cache is updated on an element of a collection that is added after calling watch

    Versions

    Please fill in the versions you're currently using:

    • apollo-ios SDK version: 0.34.0
    • Xcode version: 12.0.1
    • Swift version: 5.3

    Steps to reproduce

    I've been trying a lot of things on that one and wasn't able to find a way to fix my problem. So in my app I'm having a list of conversations, so I'm creating a watch on a query that returns the list of conversations, this is something like that:

    user {
        uuid
        firstName
        lastName
        conversations {
            uuid
            unreadMessagesCount
        }
    }
    

    In the app we use the uuid key to handle cache, so we make sure to always pass uuid in our queries to automatically handle cache update.

    So the role of the watcher I'm talking about is both to update existing conversations and also be able to catch when a new conversation is created (it can happen and not be initiated by the user, we then trigger an event from the backend that is listen from a subscription in the app). When this event happens it returns something like that

    event {
         newConversation {
              conversation {
                   uuid
                   unreadMessagesCount
                   // This is the part that adds the new conversation to the existing ones of the users in the cache
                   user {
                        uuid
                        conversations {
                              uuid
                              unreadMessagesCount
                        }
                   } 
              }
         }
    }
    

    It works great, meaning that when this event happens, the watcher is being called with the newly created conversation, but the issue is that any new cache update for that specific conversation doesn't trigger the watcher again.

    After investigating a bit, I realised that the cache is being updated because if I'm adding 3 new messages into the new conversation (setting the unreadMessagesCount to 3), the watcher doesn't get called but then if I add 1 new message into an old one, the watcher is being called with both the new message on the old conversation and the 3 new on the new one.

    So it really seems like watch is not being called again for changes on an item that wasn't in a collection when the watch was initially made. I've also take a look at https://github.com/apollographql/apollo-ios/issues/281 and making a fetch on the same query again after the event doesn't fix the issue.

    Let me know if I'm not clear on something as the whole thing is a bit complicated to explain.

    bug caching 
    opened by benoitletondor 38
  • The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...

    The version of Apollo.framework in your project requires Apollo CLI 1.2.0, but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...

    It looks like REQUIRED_APOLLO_CLI_VERSION=1.2.0 in check-and-run-apollo-cli.sh prevents us from using latest version of Apollo...

    In our iOS project at root level we have package.json with:

    {
      "name": "xxx",
      "version": "1.0.0",
      "dependencies": {
        "apollo": "^1.6.0"
      },
      "devDependencies": {},
      "repository": {
        "type": "git",
        "url": "git+https://github.com/xxx/xxx.git"
      },
      "keywords": [],
      "author": "",
      "license": "UNLICENSED",
      "private": true,
      "bugs": {
        "url": "https://github.com/xxx/xxx/issues"
      },
      "homepage": "https://github.com/xxx/xxx#readme"
    }
    

    Note it required Apollo 1.6.0.

    We have latest (0.9.2) Apollo pod integrated into our project:

    ➜  xxx git:(apollo-tweaks)  cat Podfile.lock | grep Apollo
      - Apollo (0.9.2):
        - Apollo/Core (= 0.9.2)
      - Apollo/Core (0.9.2)
      - Apollo
        - Apollo
      Apollo: 39d1adfceb6f262fc58286ec9425fd7c332877fb
    

    We do have code generation build step per recommendation here:

    APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"
    
    if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
      echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
      exit 1
    fi
    
    cd "${SRCROOT}/${TARGET_NAME}"
    
    $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=./GraphQL/schema.json ./GraphQLAPI.swift
    

    And when the build step runs it actually downgrades apollo npm package to 1.2.0:

    cd /Users/yas/code/xxx/xxx
    Queries: ./GraphQL/xxx.graphql
    +++ get_installed_version
    ++++ /Users/yas/code/xxx/node_modules/.bin/apollo -v
    +++ version='apollo/1.6.0 darwin-x64 node-v10.7.0'
    +++ [[ 0 -eq 0 ]]
    +++ echo 'apollo/1.6.0 darwin-x64 node-v10.7.0'
    ++ INSTALLED_APOLLO_CLI_VERSION='apollo/1.6.0 darwin-x64 node-v10.7.0'
    ++ are_versions_compatible apollo/1.6.0 darwin-x64 node-v10.7.0 1.2.0
    +++ cut -d/ -f2
    +++ cut -d. -f1-2
    +++ cut -d/ -f2
    +++ cut -d. -f1-2
    ++ [[ 1.6 == \d\a\r\w\i\n\-\x\6\4 ]]
    ++ echo 'The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...'
    The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...
    ++ install_apollo_cli
    ++ set -e
    ++ npm install --prefix /Users/yas/code/xxx [email protected]
    + [email protected]
    added 8 packages from 10 contributors, removed 2 packages, updated 9 packages and audited 2124 packages in 12.714s
    found 0 vulnerabilities
    
    ++ set +e
    ++ exec /Users/yas/code/xxx/node_modules/.bin/apollo codegen:generate --queries=./GraphQL/xxx.graphql --schema=./GraphQL/schema.json ./GraphQLAPI.swift
     ›   Warning: apollo update available from 1.2.0 to 1.6.0
    [?25l[15:43:18] Scanning for GraphQL queries [started]
    

    I assume this is not an intentional behavior, is it?

    opened by yas375 38
  • Can't build apollo-ios for watchOS, tvOS using Carthage

    Can't build apollo-ios for watchOS, tvOS using Carthage

    • [x] has-reproduction
    • [x] blocking

    Can't build apollo-ios for macOS, watchOS and tvOS using Carthage.

    » carthage build apollo-ios --platform macOS,tvOS,watchOS
    *** xcodebuild output can be found in /var/folders/jc/ktgtqxj574x18dscvp2vlnfw0000gn/T/carthage-xcodebuild.uRRLh2.log
    *** Skipped downloading SQLite.swift.framework binary due to the error:
    	"Bad credentials"
    *** Skipped downloading Starscream.framework binary due to the error:
    	"Bad credentials"
    *** Building scheme "SQLite watchOS" in SQLite.xcodeproj
    *** Building scheme "SQLite tvOS" in SQLite.xcodeproj
    *** Building scheme "SQLite Mac" in SQLite.xcodeproj
    *** Building scheme "Starscream" in Starscream.xcodeproj
    *** Building scheme "ApolloWebSocket" in Apollo.xcworkspace
    *** Building scheme "Apollo" in Apollo.xcworkspace
    *** Building scheme "ApolloSQLite" in Apollo.xcworkspace
    Build Failed
    	Task failed with exit code 65:
    	/usr/bin/xcrun xcodebuild -workspace /Users/kristaps/Documents/qminder/swift-api/Carthage/Checkouts/apollo-ios/Apollo.xcworkspace -scheme ApolloSQLite -configuration Release -derivedDataPath /Users/kristaps/Library/Caches/org.carthage.CarthageKit/DerivedData/10.0_10A255/apollo-ios/0.9.4 -sdk appletvsimulator -destination platform=tvOS\ Simulator,id=BE6DCEB8-5A05-4354-A0E9-C99E0F73EDCC -destination-timeout 3 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/kristaps/Documents/qminder/swift-api/Carthage/Checkouts/apollo-ios)
    
    This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/jc/ktgtqxj574x18dscvp2vlnfw0000gn/T/carthage-xcodebuild.uRRLh2.log
    

    carthage-xcodebuild.uRRLh2.log

    blocking has-reproduction dependency-management 
    opened by fassko 37
  • [Bug] 0.27.1 introduced an bug when two queries are sent one after another

    [Bug] 0.27.1 introduced an bug when two queries are sent one after another

    For this function in ApolloClient, @discardableResult public func fetch<Query: GraphQLQuery>(query: Query, cachePolicy: CachePolicy = .returnCacheDataElseFetch, context: UnsafeMutableRawPointer? = nil, queue: DispatchQueue = DispatchQueue.main, resultHandler: GraphQLResultHandler<Query.Data>? = nil) -> Cancellable

    [Bug] 0.27.1 introduced a bug when calling the function above, one after another, with different queries. One of the two queries would not call the "resultHandler" callback. Sometimes the one that does call the callback would come back with this error: dataForRequestNotFound.

    This bug does not reproduce in 0.24.1. I will check whether it reproduces in 0.25.1 and report back.

    bug networking-stack 
    opened by MaximillionMai 34
  • Directives (i.e., @include) not working

    Directives (i.e., @include) not working

    I have a fragment

    fragment QLOffer on Offer {
        id
        type
        name @include(if: $show)
    }
    

    that is then queried by

    query Offer($offerId: Int, $show: Boolean = false) {
        offer(id: $offerId) {
            ...QLOffer
        }
    }
    

    but the name is always returned.

    Some of the generated API code is

    public struct QlOffer: GraphQLFragment {
      public static let fragmentString =
        "fragment QLOffer on Offer {" +
        "  __typename" +
        "  id" +
        "  type" +
        "  name @include(if: $show)" +
        "}"
    
      public static let possibleTypes = ["Offer"]
    
      public static let selections: [GraphQLSelection] = [
        GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
        GraphQLField("id", type: .nonNull(.scalar(GraphQLID.self))),
        GraphQLField("type", type: .nonNull(.scalar(String.self))),
        GraphQLField("name", type: .nonNull(.scalar(String.self))),
      ]
    

    Any suggestions, or is this a confirmed bug currently?

    bug 
    opened by plflanagan 34
  • Incorrect code generation for enum cases containing numbers

    Incorrect code generation for enum cases containing numbers

    Summary

    We started migration to Apollo 1.0.5 (from 0.51.2), we ran the apollo-ios-cli code generation tool and then we got several compiler errors because the new tool generated a Swift enum where the cases names differs from what the 0.51.2 code generation tool generates.

    If the graphql enum case name contains all uppercase letters and numbers (e.g BEFORE1940) then only the first letter of the generated Swift enum case is lowercased (.bEFORE1940) , all the other letters remains uppercased. Apollo 0.51.2 code generation would lowercase all the letters of the enum case name (.before1940).

    Version

    1.0.5

    Steps to reproduce the behavior

    Given the following graphql enum

    enum HomeConstructionPeriod {
      BEFORE1940
      BEFORE1970
      DECADE1940
      DECADE1950
      DECADE1960
      DECADE1970
      DECADE1980
      DECADE1990
      DECADE2000
      DECADE2010
      DECADE2020
      UNKNOWN
    }
    

    Apollo 1.0.5 generates

    enum HomeConstructionPeriod: String, EnumType {
        case bEFORE1940 = "BEFORE1940"
        case bEFORE1970 = "BEFORE1970"
        case dECADE1940 = "DECADE1940"
        case dECADE1950 = "DECADE1950"
        case dECADE1960 = "DECADE1960"
        case dECADE1970 = "DECADE1970"
        case dECADE1980 = "DECADE1980"
        case dECADE1990 = "DECADE1990"
        case dECADE2000 = "DECADE2000"
        case dECADE2010 = "DECADE2010"
        case dECADE2020 = "DECADE2020"
        case unknown = "UNKNOWN"
      }
    

    While Apollo 0.51.2 generates

     public enum HomeConstructionPeriod: RawRepresentable, Equatable, Hashable, CaseIterable, Apollo.JSONDecodable, Apollo.JSONEncodable {
        public typealias RawValue = String
        case before1940
        case before1970
        case decade1940
        case decade1950
        case decade1960
        case decade1970
        case decade1980
        case decade1990
        case decade2000
        case decade2010
        case decade2020
        case unknown
    
        // ... Other code omitted ...
    }
    

    Logs

    No response

    Anything else?

    Our naming convention for graphql enums is using snake_case with UPPERCASED words for the cases (e.g. GENERIC_ERROR). In the Swift codebase we follow the classic lowercase words and camelCase (e.g. .genericError).

    All the other generated Swift enums are consistent between Apollo 1.0.5 and 0.51.2, with lowercased words and camelCase. The enum reported above is the only one we have that also contains numbers and the only one that presents the described issue with the code generation.

    bug codegen 
    opened by hispanico94 3
  • Migration 1.0 - Questions & Feedback

    Migration 1.0 - Questions & Feedback

    Question

    Hey folks!

    I've started to migrate the project to Apollo version 1.0.5 from 0.53.0. I would like to be able to make the project running as soon as possible and so I have a question regarding the migration.

    Namespace

    Is it possible to disable types namespace? As we have many type extensions, queries and mutations it's quite a lot of work to add an extension for each type that is used in the project. Also I'm not sure if I can see exactly the benefit for our project right now. So is it possible to not use a namespace?

    Types + CamelCase

    Another question is whether it's possible to provide an option to use camel case for types? Similar to what there is for enums. So that we have less errors to fix and as well to have a camel case style 🤔

    Old way:

    context.data.coreNotificationCounter
    

    New way:

    context.data.core_notificationCounter
    
    question 
    opened by wow-such-amazing 2
  • fix: GraphQLEnum value camelCase conversion strategy

    fix: GraphQLEnum value camelCase conversion strategy

    This PR refactors the .camelCase conversation strategy implementation

    • Fixes #2640
    • Fixes #2745
    • Uses the _convertFromSnakeCase implementation from JSONDecoder in Foundation with modifications. This question in the Swift forums makes me hopeful that one day we can remove this code and use a Swift standard library implementation, but we're not there yet.
    • Adds Swift enum value test cases. I checked the original PR (#2478) and oddly there weren't any in there, I'm not sure why.
    opened by calvincestari 2
  • Undefined Symbol error

    Undefined Symbol error

    Summary

    Getting the following errors when I run the app: Screenshot 2022-12-20 at 4 54 25 PM

    Xcode version: 14.2 apollo-ios -> 1.0.0 - Next Major

    Version

    1.0.0 - Next Major

    Steps to reproduce the behavior

    Build the app

    Logs

    No response

    Anything else?

    No response

    awaiting response 
    opened by Rohan-diy 8
  • Add casing strategies for property names

    Add casing strategies for property names

    Use case

    I created a new issue for this feature request since we closed #2641.

    The gist is to provide casing strategies for other parts of generated code, such as fields, similar to the current option for enums.

    Describe the solution you'd like

    No response

    feature codegen 
    opened by calvincestari 0
  • Can't build my project after adding generated files

    Can't build my project after adding generated files

    Summary

    can't build the project, get error: Multiple commands produce '/Users/santiago/Library/Developer/Xcode/DerivedData/MyProject-dnczpetajifwpedohimygtnkdewx/Build/Intermediates.noindex/MyProject.build/Debug-iphonesimulator/MyProject.build/Objects-normal/arm64/MyStruct.graphql.stringsdata'

    can't find MyQuery in scope but the class MyQuery is added rightly.

    after adding generated files.

    Version

    1.0.0

    Steps to reproduce the behavior

    running generate command

    ./apollo-ios-cli generate

    add new generated files into my project

    can't build the project, get error: Multiple commands produce '/Users/santiago/Library/Developer/Xcode/DerivedData/MyProject-dnczpetajifwpedohimygtnkdewx/Build/Intermediates.noindex/MyProject.build/Debug-iphonesimulator/MyProject.build/Objects-normal/arm64/MyStruct.graphql.stringsdata'

    can't find MyQuery in scope but the class MyQuery is added rightly.

    here is the structure of generated files: image

    using XPM with Xcode.

    Logs

    No response

    Anything else?

    No response

    awaiting response 
    opened by Santiago0412 4
Releases(1.0.5)
  • 1.0.5(Nov 21, 2022)

  • 1.0.4(Nov 18, 2022)

    Fixed

    • Fixed - Convenience initializer for mock objects without fields: When mock objects did not have any fields a convenience initializer would still be generated causing infinite recursion during initialization. #2634 Thank you to @Gois for the contribution!
    • Fixed - Ambiguous use of operator '??': When the nil coalescing operator was used on variables without a type the compiler could not determine which one to use. #2650. Thanks to @skreberem for raising the issue.
    • Fixed - Generate library for test mock target: Previous versions would generate the SPM target for test mocks but not a library to properly import it into your unit tests. #2638 Thank you to @Gois for the contribution!
    • Fixed - Podspec Swift version mismatched with SPM package version: The Swift version is now the same between the two dependency managers. #2657
    • Fixed - Conflicting configuration values: There is now an error during code generation when the given configuration has conflicting values that cannot be fulfilled. #2677
    • Fixed - DocumentType namespacing: The correct module namespacing is now used for DocumentType in generated operation code. #2679

    New

    • New - CLI version checker: This ensures that the version of the CLI being used to generate Swift code is the same as the version of the Apollo iOS dependency being used. #2659

    Changed

    • Changed - Removed SPM plug-ins: The SPM plug-ins for the CLI commands init, fetch-schema, and generate have been removed. There is a new plug-in to install the CLI and the CLI commands should be used from the command line instead. #2649
    • Changed - CLI defaults: The updated default for the output of operation files is now .inSchemaModule, and the init command now requires a module type to be specified when creating a configuration file. #2673
    Source code(tar.gz)
    Source code(zip)
    apollo-ios-cli.tar.gz(2.56 MB)
  • 1.0.3(Nov 2, 2022)

    • Fixed - Generated code produces compile error when accessing data dictionary in the InputDict struct if the name of the accessed property is hash: Dyanamic Member Lookup has been removed from InputDict to prevent potential name clashes. #2607
    • Fixed - XCFramework archive builds: @inlinable has been removed from parts of ApolloAPI that were preventing xcframework builds with the BUILD_LIBRARY_FOR_DISTRIBUTION build setting. #2613
    • Fixed - Variables type in local cache mutations is not properly namespaced: The Variables type in LocalCacheMutation now has the required prefix of GraphQLOperation to build successfully. #2615
    • Fixed - Return error if no matches to schema or operation search paths: When a schema file could not be found errors were emitted but they were not indicative of the underlying problem. There is now validation to ensure that at least one match of the schema/operation search paths is found otherwise an error is thrown. #2618
    • Fixed - File generation should ignore the .build/.swiftpm/.Pods folders: If code generation was executed from a path where subfolders contained the apollo-ios repo, it would find internal test schemas and fail. These special folders are now ignored. #2628
    • Fixed - Download schema relative to root URL: Even though a root URL could be provided it was not being used in all schema download logic to output the downloaded schema file to the correct locaiton. This is now fixed. #2609 Thanks to @Anteo95 for the contribution.
    Source code(tar.gz)
    Source code(zip)
    apollo-ios-cli.tar.gz(2.51 MB)
  • 1.0.2(Oct 22, 2022)

    • Fixed - Not generating code for subtypes only used as input to mutations: If you are using a JSON format schema that was fetched via GraphQL introspection code generation will now generate all referenced subtypes. #2583 Thank you to @vrutberg for reporting the issue.
    • Fixed - When using the test mock, touching a GraphQLEnum property will cause a crash: JSON Encoding the mocks into the SelectionSet.DataDict was causing CustomScalar values to get encoded into their JSON values. The mock data is now converted into the correct format for the SelectionSet.DataDict. #2584 Thank you to @asapo for reporting the issue.
    • Fixed - Add namespace for ApolloAPI types in generated code: The Apollo DocumentType enum is now correctly namespaced in generated code. #2585 Thank you to @matijakregarGH for reporting the issue.
    • Fixed - Problems with schema name in generated code:
      • Schema name is now correctly cased for generated code namespacing. #2586 Thank you to @pchmelar for reporting the issue.
      • The schema name is now not allowed to match any referenced schema type, entity field, or entity list field names. #2589
    • Fixed - Test mocks crash when touching array of objects: Test mock list of objects is now correctly converted into selection set data. #2591 Thank you to @konomae for reporting the issue.
    • Fixed: GraphQLNullable nil coalescing: @exported import statements now ensure that the operator overload is imported when using the generated models. #2600 Thank you to bassrock for reporting the issue.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Oct 12, 2022)

    Fixes

    • Fixed - apollo-ios-cli code generation on CocoaPods installation: All required resources for the CLI are now bundled correctly. This was an issue in CocoaPods installations where the generate command of apollo-ios-cli would result in a fatal error. #2548 Thank you to @ilockett for reporting the issue.
    • Fixed - Xcode integration for Swift Package Plugins: The SwiftPM plugins now support XcodePluginContext from Xcode 14 and accepts the additional command line options that Xcode sends. #2554 Thank you to @SilverTab for reporting the issue.
    • Fixed - Escaping input param names: Input parameter names recognized as reserved words are now escaped to prevent build errors. #2561 Thank you to @puls for the contribution.
    • Fixed - Multiline deprecation messages: Deprecation messages that span multiple lines would previously result in build errors. #2579 Thank you to @TizianoCoroneo for the contribution.

    Changes

    • Changed - Warnings for deprecated enums: Deprecated enum cases are no longer annotated with the Swift @available attribute. They will now have comments indicating their deprecated status. #2579
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 2, 2022)

    This is the first major version release of Apollo iOS! 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.

    In a nutshell, v1.0.0 brings:

    • A new code generation engine built entirely in Swift
    • Improvements to the generated models
    • Syntax and performance improvements across the entire library

    There is documentation and a blog post coming soon. Feel free to ask questions by either opening an issue on our GitHub repo, or joining the community.

    Thank you to all contributors who have helped us get to this first major release! ❤️

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-rc.1(Sep 21, 2022)

    This is the first Release Candidate for Apollo iOS 1.0. The Release Candidate is a fully featured and code-complete representation of the final 1.0 version. This includes full feature parity with the 0.x.x releases.

    API breaking changes are not expected between the Release Candidate and the General Availability (GA) release. The only code changes will be non-breaking bug fixes due to user feedback. The Release Candidate does not have complete documentation or usage guides, which will be completed prior to GA.

    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: Option to Include Deprecated Input Arguments on Fields During Schema Download Thanks to @dave-perry for this addition!
    • Fixed: Code Generation Config JSON File Compatibility
      • Previously, the apollo-codegen-config.json file used by the Apollo CLI needed to contain values for all optional fields. When new codegen options were added, this would cause errors until all newly added options has values provided.
      • The Codable implementation for the ApolloCodgenConfiguration has been implemented manually to prevent this. Now, only required fields must be provided, all optional fields can be omitted from the config file safely.
      • The CLI's init command also now generates a template config file with only the required fields.
    • Fixed: Swift Keywords are escaped when used as names of Input Parameters
    • Fixed: Compilation Error when using @skip and @include conditions on the same field
    • Fixed: Added permissions request to SPM Code Generation Plugin
      • When running the code generation plugin, you will be prompted to give permission for the plugin to write to the package directory.
      • This permission check can be avoided by passing the --allow-writing-to-package-directory flag when executing the plugin command.
    • Fixed: APQ Operations Will no Longer be Retried when Unrecognized if using .persistedOperationsOnly
      • .persistedOperationsOnly is for use with allow-listed operations only. If an operation identifier is not recognized by the server, there is no way to register the operation in this configuration.
    • Breaking: Updated ApolloAPI internal metadata properties to be __ prefixed.
      • Generated GraphQL files expose certain properties/functions that are consumed by the Apollo library during GraphQL Execution. These members must be public in order to be exposed to Apollo, but are not intended for external consumption. We have added underscore prefixes to each of these members to signify that intention, using __ for GraphQL Metadata (in alignment with the GraphQL Specification) and _ for Apollo's utility and helper functions.
      • The affected signatures are:
        • SelectionSet.schema -> SelectionSet.__schema
        • SelectionSet.selection -> SelectionSet.__selection
        • JSONEncodable.jsonValue -> JSONEncodable._jsonValue
        • JSONDecodable.init(jsonValue:) -> JSONDecodable.init(_jsonValue:)
        • AnyHashableConvertible.asAnyHashable -> AnyHashableConvertible._asAnyHashable
        • OutputTypeConvertible.asOutputType -> OutputTypeConvertible._asOutputType
        • GraphQLOperation.variables -> GraphQLOperation._variables
        • LocalCacheMutation.variables -> LocalCacheMutation._variables
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.4(Sep 10, 2022)

    This is the fourth Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.

    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.

    • Breaking: Generated Files now have the file extension .graphql.swift.
      • This allows you to clearly distinguish which files in your project are Apollo generated files.
      • Generated template files that are user-editable will still have the .swift file extension.
        • CustomScalar templates as well as the SchemaConfiguration file are user-editable. Once these are generated, they are never overwritten by future code generation execution.
      • This change is also necessary for the identification of generated files for the pruning functionality.
    • New: Pruning of Unused Generated Files
      • Generated files that no longer should exist are automatically deleted now. This occurs when a .graphql file is removed from your project. The generated file will also be deleted the next time code generation is run.
      • This can be disabled with the new pruneGeneratedFiles codegen option.
      • Breaking: Automatic Deletion will not delete files generated in previous Alpha/Beta versions.
        • Only files with the .graphql.swift file extension will be deleted.
        • If you have used previous Alpha/Beta versions, you will need to delete your generated files manually one last time before running code generation with this version.
    • New: Enum Case Names are Converted to Camel Case in Generated Enums.
      • Breaking: This is enabled by default, your call sites will need to be updated.
      • Camel case conversion for enum cases can be disabled with the new conversionStrategies.enumCases codegen option.
      • Thanks @bannzai for this one!
    • Fixed: Swift Keywords are escaped when used as names of Enum Values Thanks @bannzai for the fix!
    • Fixed: Compilation Error when Using Fragment with Lowercased Name This was an edge case that only occured when referencing a nested, merged selection set from the lowercase named fragment.
    • Fixed: Retain Cycle in ReadTransaction Thanks @lorraine-hatch for the fix!
    • Fixed: String jsonValue Initializer for Large Numbers Thanks @Almaz5200 for the fix!
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.3(Aug 29, 2022)

    This is the third Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.

    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.

    • Breaking: Changed the generated Schema files
      • The schema will now have two generated files, SchemaMetadata.swift and SchemaConfiguration.swift.
      • We wanted to more clearly separate the parts of the schema that are generated for you (metadata) from the parts that you can configure yourself (configuration).
      • *If you were using the last beta, you’ll need to move your cache key resolution logic into SchemaConfiguration.swift. You should also delete the old generated files.
      • We will be implementing automatic deletion of generated files that should no longer be part of your project in a future beta, so you won't need to delete those files manually anymore.
    • New: Added SPM Plugin for Code Generation CLI
      • When including Apollo iOS via Swift Package Manager, the Code Generation CLI is now accessible as an SPM Plugin.
      • After installing the apollo-ios package, run swift package --disable-sandbox apollo-initialize-codegen-config to create the codegen configuration file.
      • Then you can run swift package --disable-sandbox apollo-generate to run code generation.
      • The --disable-sandbox or --allow-writing-to-directory . arguments must be used when running the Code Generation CLI via the SPM plugin to give the plugin permission to write the generated files to the output directory configured in your codegen configuration file.
    • Fixed: Compilation errors when schema types had lowercase names
    • Fixed: Codegen engine crashing in specific situations
      • There were some bugs in the codegen compiler when merging nested fragments with non-matching parent types and using default values for input object list fields.
    • Fixed: Issues with websocket reconnections Thanks @STomperi for the fix!
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.2(Aug 16, 2022)

    This is the second Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.

    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.

    • Breaking: Changed API for Cache Key Configuration: Cache Key Resolution is now easier to configure. See CacheKeyInfo for examples and documentation.
    • Breaking: Changed API for generated Schema Types to support dynamic types The API for generated schema types now initializes instances of Object, Interface, and Union for each corresponding type in your schema. These are still generated by the code generation engine. This differs from the previous API which generated static types that were subclasses of Object, Interface, and Union. The change provides the API to support the future addition of dynamic types added to your schema at runtime.
    • New: Codegen CLI will now automatically create output directories: You no longer are required to have already created all intermediary directories for your codegen output paths prior to running code generation.
    • New: CodegenCLI is built locally with CocoaPods installations: This is to ensure that the version of the Codegen CLI is the same as ApolloCodegenLib. This behavior will be extended to Swift Package Manager installations too.
    • New: Swift Keywords are escaped when used as names of fields or types in generated objects: Previously, using Swift keywords (eg. self, protocol, Type) as the names of fields in your operations or types in your schema would cause compilation errors in your generated code. Now, these names will be escaped with backticks to prevent compiler errors. The names __data and fragments cannot be used as field names as they conflict with Apollo's generated object APIs Using these names will result in a validation error being thrown when attempting to run the code generation engine.
    • Fixed: Fragments with lowercase names caused compilation errors: This bug is fixed. Fragments with lowercase names will be correctly uppercased when referencing the generated Fragment objects.
    • Fixed: Build errors in Xcode 14/Swift 5.7: The library was updated to support the Swift 5.7 language version. Swift 5.6 is still supported.
    • Fixed: Xcode 14 does not support Bitcode: Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14.
    • Fixed: "No such module ApolloAPI" error when using CocoaPods: The podspec was not configured to import all required source files and some import statements were unnecessary in a CocoaPods environment. A code generation configuration option was added to order to ensure generated files are generated with the correct import statements in a CocoaPods environment. When generating code for a project that includes Apollo via Cocoapods, you must set the cocoapodsCompatibleImportStatements option to true in your ApolloCodegenConfiguration. When using the Codegen CLI that is built for you during pod install the apollo-ios-cli init command will default this option to true. When building the Codegen CLI in by other method, this option will default to false.
    • Removed: ApolloUtils target no longer necessary: The things that used to be shared here are actually no longer shared. There is no code shared between the Apollo and ApolloCodegenLib targets.
    • Removed: ApolloCodegenConfiguration.validation: This method was incorrectly requiring destination paths to exist before code generation. Once that was removed it was no longer necessary. Any errors that are encountered with destination output paths will be raised during code generation.
    Source code(tar.gz)
    Source code(zip)
  • 0.53.0(Jul 29, 2022)

    • Remove all instances of bitcode as not supported in Xcode 14: Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14. #2398 - Thanks to @stareque-atlassian for the contribution!
    Source code(tar.gz)
    Source code(zip)
  • 0.52.0(Jul 14, 2022)

    • Add codegen option for excludes: There is a new property on the codegen configuration options to allow files matching the pattern to be excluded, in the case they are found in the includes path. #2205 - Thanks to @bannzai for the contribution!
    • Fixed - Using the graphql_transport_ws protocol could result in 4400 errors from the server: The correct protocol message is now being sent to the server to end communication. #2320
    • Replace print statement with CodegenLogger.log: All codegen output is logged with CodegenLogger which can be disabled if needed. #2348 - Thanks to @hiltonc for the contribution!
    • Expose GraphQLResultError path string: Adds a new publicly available computed property to GraphQLResultError which just exposes the path description. #2361 - Thanks to @joshuashroyer-toast for the contribution!
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.1(Jul 1, 2022)

    This is the first Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.

    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: Additional Generated Code Output Configuration Options.
      • queryStringLiteralFormat: Configures how the generated operations render the operation document source. Either multi-line (as defined in operation definition) or minified to a single line.
      • schemaDocumentation: Documentation of fields and objects from your schema will now be included as in-line documentation on generated objects. This can be disabled by setting schemaDocumentation to .excluded in your codegen configuration.
      • warningsOnDeprecatedUsage: Adds warning annotation when using fields and arguments in generated operations that are deprecated by the schema.
      • additionalInflectionRules: Allows you to configure custom singularization rules for generated fields names.
    • New: Support Automatic Persisted Queries: APQs are now fully functional. Note: Legacy operation safelisting support may experience issues in some cases. If you have problems using operation safelisting, please create an issue so that we may understand and resolve the edge cases in the safelisting process.
    • Fixed: Singularization of plural names for non-list fields.
    • Fixed: Runtime failure on execution of operations with InputObjects.
    • Fixed: __typename field no longer generated when manually included: __typename is automatically included in all operations and fragments and has a default property on all Selection Sets. Generating the field was redundant and caused compilation errors.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.8(Jun 27, 2022)

    This is the eighth 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: Added Equatable and Hashable Conformance to public API Models: Object's like GraphQLRequest and GraphQLError now can be compared!
    • New: Code Generation now supports Schema Extensions.
    • Fixed: Namespacing and Access Control on Generated Models: Generated models were failing to compile due to namespacing and access control issues in certain code generation configurations. This is fixed now!
    • Improved: Custom Scalar Default Float Behavior: If the response for a custom scalar is provided as a Float, it will automatically be converetd to a String (just like it's always done for Int).
    • Improved: GraphQL Float now treated as Swift Double: The Float defined in the GraphQL spec is actually compliant with a Swift Double. Generated code will now generate Swift code with fields of type Double for GraphQL Float.
    • Improved: Rename SelectionSet.data to SelectionSet.__data: This is to prevent naming conflicts with GraphQL fields named data.
    • Fixed: graphql_transport_ws protocol now sends 'complete' to end subscription: The protocol implementation was previously sending the wrong message to close the connection.
    • Improved: Generated Operations Folder Structure: The generated output folder structure for fragments and operations are now organized into sub-folders.
    • New: Introspection Schema Download can output JSON: Schema downloads via Introspection now support output as JSON instead of only SDL. Note that Apollo Registry schema downloads still only support SDL as the output.
    Source code(tar.gz)
    Source code(zip)
    apollo-ios-cli_source.tar.gz(9.70 KB)
  • 1.0.0-alpha.7(Jun 15, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
    apollo-ios-cli_1.0.0-homebrew_test_source.tar.gz(9.64 KB)
  • 1.0.0-alpha.6(Jun 7, 2022)

    This is the sixth 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 - Objects and InputObjects are now equatable: Many objects now conform to AnyHashable bringing with them the ability to conform to Equatable, this should make tests easier to write.
    • Change - GraphQLOperation fields are now static: Previously an instance of a GraphQLOperation was required to query any of it's properties, you can do that on the type now.
    • Fixed - Nested fragment type cases: Nested fragment type cases were not being generated causing a crash in selection set generation.
    • New - Code generation now has a CLI: A new command line executable has been built and will be available on Homebrew very soon! Check it out here.
    • Fixed - SelectionSet and InlineFragment protocol definitions: These were incorrectly being generated within the namespace when a module of type .embeddedInTarget was being used.
    • Fixed - Test mock convenience initializers: These were incorrectly defining parameter types for Interface and Union fields and the generated package could not successfully build.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.5(May 19, 2022)

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

    • Test Mocks are now supported!
      • Test mocks can be generated to make it much easier to create mocks of your generated selection sets for unit testing.
      • This long requested feature can be enabled in your code generation config with the option config.output.testMocks.
      • Once you've generated test mocks, import the new ApolloTestSupport target (as well as your generated mocks) in your unit tests to start.
      • More documentation for test mocks will be coming soon. In the mean time, here is some example usage:
    let mockDog = Mock<Dog>()
    mock.species = "Canine"
    mock.height = Mock<Height>(feet: 3, inches: 6)
    
    // To mock an object in a generated operation:
    let generatedDogMock: AnimalQuery.Data.Animal = AnimalQuery.Data.Animal.mock(from: mockDog)
    
    // To mock an entire query:
    let queryMock = Mock<Query>()
    queryMock.animals = [mockDog]
    let generatedSelectionSetMock: AnimalQuery.Data = AnimalQuery.Data.mock(from: queryMock)
    
    • GraphQLNullable and GraphQLEnum from the ApolloAPI target are now exported by your generated operations. This prevents you from having to import ApolloAPI everywhere that you are consuming your generated models.
    • CacheKeyProvider now supports grouping multiple types that share key uniqueness.
    • Lots of performance improvements
      • Using StaticString instead of String in generated files.
      • Added @inlinable to many ApolloAPI functions consumed by generated code.
      • And more!
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.4(Apr 15, 2022)

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

    • Client Controlled Nullability (CCN) is now supported!
      • CCN is an experimental new feature addition to GraphQL. This feature allows you to override the optionality of fields from a schema in your client operations. CCN can help you create cleaner generated models that require less optional unwrapping.
      • You can read more about CCN here.
      • Because CCN is an experimental feature, the API is subject to change before its final release.
      • Apollo iOS 1.0.0 is the first client to provide support for this new functionality! Huge thanks to @twof!
    • Fixed - Names of generated objects are now correctly uppercased.
    • Fixed - Names of inline fragments with inclusion conditions were sometimes generated incorrectly.
    • Fixed - __typename field is now selected by executor on all entities automatically.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.3(Apr 12, 2022)

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

    • Include/Skip Directives are now supported!
      • Adding @include/@skip directives to fields, inline fragments, or fragment spreads will now generate code that respects the optionality of these conditionally included selections.
    • Changed - Generated TypeCase renamed to InlineFragment These are now used for both type cases and inline fragments that are conditionally included using @include/@skip directives.
    • Custom Scalars are now supported!
      • Template Files will be generated for custom scalars. The template files typealias each custom scalar to a String by default. These generated files can be edited to provide custom functionality for advanced custom scalars. Custom scalar template files that have been edited will not be overwritten on later code generation executions.
    • Improved multi-module support
      • Including your generated code using package managers other than SPM can be done using the .other option for moduleType in your code generation configuration.
    • Nil Coalescing Operator added to GraphQLNullable
      • This allows for optional variables to easily be used with GraphQLNullable parameters and a default value
    var myVar: GraphQLNullable<String>
    let optionalString: String?
    
    // Before
    myVar = optionalString.map { .some($0) } ?? .none
    
    // After
    myVar = optionalString ?? .none
    
    • Fixed - fragments not accessible on generated SelectionSets.
    • Fixed - __typename is now added to all operation and fragment definitions.
    • Fixed - Missing Generated Interface Types
      • Interface types that were only referenced as an implemented interface of a referenced concrete type were not being generated previously.
    Source code(tar.gz)
    Source code(zip)
  • 0.51.2(Mar 18, 2022)

  • 0.51.1(Mar 7, 2022)

    • Expose request body creation to better support custom interceptors: Enable lazy access to the request body creation for leverage in custom built interceptors, since JSONRequest.toURLRequest() encapsulates the creation. This enables the GraphQLMap to be accessed without re-creating the body. #2184 - Thanks to Rick Fast for the contribution.
    Source code(tar.gz)
    Source code(zip)
  • 0.51.0(Feb 28, 2022)

    • Allow periods in arguments to be ignored when parsing cacheKeys: If your query arguments include periods they will no longer cause broken cache keys. This means the cached data for those queries can be correctly found and returned. The caveat with this change though is that if you use a persisted cache, after the upgrade you could see cache misses and the data would be refetched. #2057 - Thanks to Hesham Salman for the contribution.
    • Fixed - Sendable class JavaScriptError cannot inherit from another class other than NSObject: Xcode 13.3 introduced some additional requirements for Error types and JavaScriptError did not conform causing compile errors in ApolloCodegenLib. This change disables Sendable type checking for JavaScriptError while maintaining type-safety across concurrency boundaries. #2147 - Thank you to Tiziano Coroneo for the contribution.
    • Fixed - Watcher using a policy that shouldn't hit the network, can still hit the network: If the cache policy given to the watch(query:cachePolicy:) method of ApolloClient was .returnCacheDataDontFetch it could still trigger a remote fetch of the query. - Thank you to Peter Potrebic for raising the issue.
    • BREAKING CHANGE - graphql-ws Protocol Support: We've added official support for the graphql-ws library and its graphql-transport-ws protocol. This is a breaking change because the WebSocket initializers now require you to specify which protocol to use.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.2(Feb 22, 2022)

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

    • Operation Variables and Field Arguments are now supported!
    • Fixed - Capitalized field names generate code that doesn't compile #2167
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.1(Feb 8, 2022)

    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.

    Source code(tar.gz)
    Source code(zip)
  • 0.50.0(Nov 17, 2021)

    • Dropped SPM support for Swift 5.2: The minimum version of the Swift tools and language compatibilty required to process the SPM manifest is Swift 5.3. This means a minimum of Xcode version 12 is required for Swift Package Manager support. #1992
    • Removed unnecessary assertion failure: The completion handler on returnResultAsyncIfNeeded is defined as optional but if not included would cause debug builds to crash with an assertionFailure in the case of a failure of the Result. #2005 - Thank you to Richard Topchii for raising this issue!
    • CachePolicy.default is now a stored property: It is now easier to configure a different default value for the CachePolicy property on any ApolloClient instance instead of having to override it in a subclass. #1998 - Thank you to Tiziano Coroneo for the contribution!
    • Exposed cacheKey function as public: The access modifier of this function on GraphQLField has changed from internal to public. It is not recommended to rely on internal behaviour of the cache, and this is subject to change in future major versions. #2014 - Thank you to Peter Potrebic for the discussion!
    • GET method support for ApolloSchemaDownloader: Introspection-based schema downloads can now be queried using a GET request. #2010 - Thank you to Mike Pitre for the contribution!
    • Updated to version 2.33.9 of the Apollo CLI: This update will add __typename fields to inline fragments in operations to match the output from the client:push CLI command which used for operation safelisting. This should not affect the behaviour of your operations. #2028.
    • Updated to version 0.13.1 of SQLite.swift: This update brings in some iOS 14 fixes and new table functionality such as upsert and insertMany. #2015 - Thank you to Hesham Salman for the contribution.
    Source code(tar.gz)
    Source code(zip)
  • 0.49.1(Sep 24, 2021)

    • ApolloSchemaDownloadConfiguration.HTTPHeader initializer was not public: The struct initializer that Swift automatically generates is marked with the internal access level, which meant that custom HTTP headers could not be added to an instance of ApolloSchemaDownloadConfiguration. #1962 - Thank you to Nikolai Sivertsen for the contribution!
    • Documentation update: Fixed an inline code block that had specified language where such specification is not supported. #1954 - Thank you to Kim Røen for the contribution!
    • Fix - ApolloCodegenOptions could not find schema input file: - If you created ApolloSchemaDownloadConfiguration and ApolloCodegenOptions objects using only output folders the default output filename for the schema download was different from the default schema input filename for codegen. #1968 - Thank you to Arnaud Coomans for finding this issue!
    Source code(tar.gz)
    Source code(zip)
  • 0.49.0(Sep 21, 2021)

    • Breaking - Schema download is now Swift-based: The dependency on the Apollo CLI (Typescript-based) for schema downloading has been removed. Schema downloading is now Swift-based, outputs GraphQL SDL (Schema Definition Language) by default, and is maintainable/extensible within apollo-ios with full API documentation. This is a breaking change because some of the API signatures have changed. Swift scripting offers a convenient way to perform certain operations that would otherwise require the command line - it's worth a look if you haven't tried it yet. #1935
    Source code(tar.gz)
    Source code(zip)
  • 0.48.0(Sep 2, 2021)

    • Customizable subscription message identifiers: The WebSocketTransport initializer can be configured with a subclass of OperationMessageIdCreator to provide a unique identifier per request. The default implementation is ApolloSequencedOperationMessageIdCreator and retains the current behavior of sequential message numbering. #1919 - Thank you to Clark McNally for the contribution!
    • AWS AppSync Compatibility: Apollo-ios will now correctly handle the start_ack message that AWS AppSync servers respond with when a subscription is requested. #1919 - Thank you to Clark McNally for the contribution!
    • Updated to version 2.33.6 of the Apollo CLI: Applies some new vulnerability patches to the CLI, but should not change any output. #1929
    • Improved documentation: Clarification of cache normalization concepts. #1710 - Thank you to Daniel Morgan for the contribution!
    Source code(tar.gz)
    Source code(zip)
  • 0.47.1(Aug 17, 2021)

  • 0.47.0(Aug 17, 2021)

    • Breaking - Removed Starscream dependency: Due to dependency management conflicts it has become easier for us to maintain our WebSockets as part of the ApolloWebSockets target instead of an external dependency on a forked version of Starscream. #1906
      • Removed Starscream as an external dependency in Cocoapods and Swift Package Manager.
      • The DefaultWebSocket implementation has been replaced with WebSocket.
    • Fixed - clearCache not using the provided callback queue: ApolloClient was not passing the provided callback queue to ApolloStore and therefore the completion block for clearCache was being called on the main queue. #1904, #1901 - Thank you to Isaac Ressler for the contribution!
    • Removed - Swift playground: The playground has been moved to a separate repository. #1905
    Source code(tar.gz)
    Source code(zip)
Owner
Apollo GraphQL
A community building flexible open source tools for GraphQL.
Apollo GraphQL
Meet Corvus, the first strongly declarative server-side framework.

Corvus Corvus is the first truly declarative server-side framework for Swift. It provides a declarative, composable syntax which makes it easy to get

null 42 Jun 29, 2022
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support

Networking was born out of the necessity of having a simple networking library that doesn't have crazy programming abstractions or uses the latest rea

Nes 1.3k Dec 17, 2022
Twitter-Client - A twitter client that allow users to view tweets on their iphone

Project 3 - Twitter Client Name of your app is a basic twitter app to read your

null 0 Feb 7, 2022
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

Always Right Institute 116 Aug 6, 2022
SoundCloud client written on Swift

SoundCloud client written on Swift to integrate it easily with your apps. Features Fluent interface based on Models Reactive API with ReactiveCocoa 4.

Pedro Piñera Buendía 564 Mar 24, 2022
Open source Reddit client for iOS built entirely in Swift

Area51 Area51 is an open source Reddit client for iOS built entirely in Swift! Get the public beta on TestFlight Join the public Slack channel to coll

Kris 141 Dec 26, 2022
Socket.io iOS and OSX Client compatible with v1.0 and later

SocketIO-Kit ⚠️ This project is no longer maintained. Please use the official framework Socket.IO-Client-Swift. SocketIO-Kit is a Socket.io iOS client

Ricardo Pereira 140 Mar 9, 2022
Frp Client Framework for iOS

Frp Client Framework for iOS README | 中文文档 base on https://github.com/fatedier/frp v0.37.1(the lastest at 2021.10) ios framework,it can run on your ip

zhouhao 5 Dec 13, 2022
Minecraft server RCON client for iOS/macOS

iRCON Minecraft server RCON client for iOS/macOS. Features Full remote console window Player list with ability to easily op, kick, ban, etc. Quickly s

JackMacWindows 7 Dec 26, 2022
SSH and SFTP client for iOS

Parrot.Flo SSH and SFTP client for iOS https://parrot-flo.site BUG ? Please Submit new issue Contact me Hey ? do you want ask about all my tools ? you

0x 4 Feb 16, 2022
The HTTP library used by the Spotify iOS client

Authentication and back-off logic is a pain, let's do it once and forget about it! This is a library that allows you to centralise this logic and forg

Spotify 625 Nov 20, 2022
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.

This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and Apple TV app. With this Framework you can create iPh

Prioregroup.com 479 Nov 22, 2022
An iOS library to route API paths to objects on client side with request, mapping, routing and auth layers

WANetworkRouting Developed and Maintained by ipodishima Founder & CTO at Wasappli Inc. Sponsored by Wisembly A routing library to fetch objects from a

null 10 Nov 20, 2022
iOS Project Manager Client

08-iOS-Project-Manager-Client 프로젝트 매니저 STEP 1 프로젝트 할일 리스트 기능구현 UI구현방식 : 코드 아키텍쳐 : ProjectManagerViewController : NavigationViewController위에 StackView(

Kioding87 1 Nov 19, 2021
The official iOS client library for api.video

api.video iOS client api.video is the video infrastructure for product builders.

api.video 8 Dec 2, 2022
Conforming WebSocket (RFC 6455) client library for iOS and Mac OSX

SwiftWebSocket Conforming WebSocket (RFC 6455) client library for iOS and Mac OS

null 0 Dec 24, 2021
iOS client for the Brewfactory project - brew your own beer

BrewMobile iOS client for the Brewfactory project. Read the stories of upgrading BrewMobile to ReactiveCocoa & Swift on AllTheFlow. What is this? App

brewfactory 195 Dec 18, 2022
A simple Last.fm client for iOS

vinylogue for Last.fm Vinylogue is a simple Last.fm client for iOS that shows you and your friends' charts from previous years. App Store (it's free).

Chris Trott 112 Dec 18, 2022
Metatext A free, open-source iOS Mastodon client.

Metatext A free, open-source iOS Mastodon client. Contributing Bug Reports GitHub is used for bug tracking. Please search existing issues and create a

Metabolist 702 Jan 9, 2023