{"id":17897663,"url":"https://github.com/bdbergeron/apollo-ios-extensions","last_synced_at":"2025-07-11T15:17:53.932Z","repository":{"id":202579974,"uuid":"707494841","full_name":"bdbergeron/apollo-ios-extensions","owner":"bdbergeron","description":"Helpful extensions to the apollo-ios package.","archived":false,"fork":false,"pushed_at":"2024-05-31T21:11:20.000Z","size":7300,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T11:23:14.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdbergeron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-20T02:58:29.000Z","updated_at":"2023-10-20T04:41:25.000Z","dependencies_parsed_at":"2023-11-01T00:20:07.745Z","dependency_job_id":"3e5edc5d-a854-4cec-8c55-a27775f5cd37","html_url":"https://github.com/bdbergeron/apollo-ios-extensions","commit_stats":null,"previous_names":["bdbergeron/apollo-ios-extensions"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bdbergeron/apollo-ios-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdbergeron%2Fapollo-ios-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdbergeron%2Fapollo-ios-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdbergeron%2Fapollo-ios-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdbergeron%2Fapollo-ios-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdbergeron","download_url":"https://codeload.github.com/bdbergeron/apollo-ios-extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdbergeron%2Fapollo-ios-extensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264837875,"owners_count":23671108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T15:13:59.781Z","updated_at":"2025-07-11T15:17:53.907Z","avatar_url":"https://github.com/bdbergeron.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apollo-ios-extensions\nHelpful extensions to the [apollo-ios](https://github.com/apollographql/apollo-ios) package.\n\n[![Build and Test](https://github.com/bdbergeron/apollo-ios-extensions/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/bdbergeron/apollo-ios-extensions/actions/workflows/build-and-test.yml)\n[![codecov](https://codecov.io/gh/bdbergeron/apollo-ios-extensions/graph/badge.svg?token=e6ZQ0eQaJk)](https://codecov.io/gh/bdbergeron/apollo-ios-extensions)\n[![CodeFactor](https://www.codefactor.io/repository/github/bdbergeron/apollo-ios-extensions/badge)](https://www.codefactor.io/repository/github/bdbergeron/apollo-ios-extensions)\n\n\n## Features\n\n### ApolloClientProtocol Default Values\nIt's wonderful we're provided with `ApolloClientProtocol`, which `ApolloClient` conforms to.\nHowever, the `ApolloClient` implementation provides default parameter values that `ApolloClientProtocol`\ndoesn't provide. Consider this a non-issue now!\n\n### MockApolloClient\nWant to test your app's code around `ApolloClient`? Look no further than `MockApolloClient`!\nThis mock object conforms to `AppoloClientProtocol` and allows you to stub responses to queries,\nmutations, and subscriptions.\n\n```swift\nfunc test_query() throws {\n  let apolloClient = MockApolloClient()\n  apolloClient.fetchResult = { parameters in\n    let data = TestQuery.Data(items: .init(edges: [\n      .init(node: .init(id: \"1\",name: \"Brad\")),\n    ]))\n    return .success(GraphQLResult(data: data))\n  }\n\n  let expectation = expectation(description: #function)\n  apolloClient.fetch(query: TestQuery()) { result in\n    expectation.fulfill()\n    switch result {\n    case .success(let result):\n      XCTAssertEqual(result.data?.items.edges.count, 1)\n      XCTAssertEqual(result.data?.items.edges[0].node.id, \"1\")\n      XCTAssertEqual(result.data?.items.edges[0].node.name, \"Brad\")\n    case .failure(let error):\n      XCTFail(\"Unexpected error: \\(error)\")\n    }\n  }\n  wait(for: [expectation], timeout: 1.0)\n}\n```\n\n### Testing / Mocking GraphQLResult\nWant to test your generated GraphQL data models against stable JSON data that you control?\n`GraphQLResult.mockedJSONResponse` is your answer!\n\nMock your response, like `items.json` in your app bundle:\n```json\n{\n  \"data\": {\n    \"items\": {\n      \"__typename\": \"ItemCollection\",\n      \"edges\": [\n        {\n          \"__typename\": \"ItemCollectionEdge\",\n          \"node\": {\n            \"__typename\": \"Item\",\n            \"id\": \"1\",\n            \"name\": \"Brad\"\n          }\n        }\n      ]\n    }\n  }\n}\n```\n\nThen test against that mock response:\n```swift\nfunc test_mockedJSONResponse() throws {\n  let url = try XCTUnwrap(Bundle.module.url(forResource: \"items\", withExtension: \"json\"))\n  let response = try GraphQLResult.mockedJSONResponse(\n    for: TestQuery(),\n    jsonURL: url)\n  let data = try XCTUnwrap(response.data)\n  XCTAssertEqual(data.items.edges.first?.node.__typename, \"Item\")\n  XCTAssertEqual(data.items.edges.first?.node.id, \"1\")\n  XCTAssertEqual(data.items.edges.first?.node.name, \"Brad\")\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdbergeron%2Fapollo-ios-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdbergeron%2Fapollo-ios-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdbergeron%2Fapollo-ios-extensions/lists"}