{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/apollo-ios/issues/226","repository_url":"https://api.github.com/repos/apollographql/apollo-ios","labels_url":"https://api.github.com/repos/apollographql/apollo-ios/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-ios/issues/226/comments","events_url":"https://api.github.com/repos/apollographql/apollo-ios/issues/226/events","html_url":"https://github.com/apollographql/apollo-ios/issues/226","id":304772811,"number":226,"title":"GraphQL Cache policy in swift not working","user":{"login":"dikenshah1212","id":35653171,"avatar_url":"https://avatars1.githubusercontent.com/u/35653171?v=4","gravatar_id":"","url":"https://api.github.com/users/dikenshah1212","html_url":"https://github.com/dikenshah1212","followers_url":"https://api.github.com/users/dikenshah1212/followers","following_url":"https://api.github.com/users/dikenshah1212/following{/other_user}","gists_url":"https://api.github.com/users/dikenshah1212/gists{/gist_id}","starred_url":"https://api.github.com/users/dikenshah1212/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dikenshah1212/subscriptions","organizations_url":"https://api.github.com/users/dikenshah1212/orgs","repos_url":"https://api.github.com/users/dikenshah1212/repos","events_url":"https://api.github.com/users/dikenshah1212/events{/privacy}","received_events_url":"https://api.github.com/users/dikenshah1212/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-13T13:51:25Z","updated_at":"2018-03-14T03:54:39Z","closed_at":null,"author_association":"NONE","body":"<!--**Issue Labels**\r\nWhile not necessary, you can help organize our issues by labeling this issue when you open it.  To add a label automatically, simply [x] mark the appropriate box below:\r\n\r\n- [ ] has-reproduction\r\n- [ ] feature\r\n- [ ] blocking\r\n- [ ] good first issue\r\n\r\nTo add a label not listed above, simply place `/label another-label-name` on a line by itself.\r\n-->\r\n**CachePolicy.returnCacheDataAndFetch not working**\r\n\r\nIn my application, I am using graphQL using Apollo client framework. An application has offline support and for this, I am using \"returnCacheDataAndFetch\" cache policy but unfortunately, It's not working in the app. Below is my query string.\r\n\r\n```\r\nquery fetchCompanyUsers {\r\n    company {\r\n        id\r\n        users {\r\n            totalCount\r\n            edges {\r\n                node {\r\n                    id\r\n                    firstName\r\n                    lastName\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\nWhen I debug code It always fetch data from network not from cache. Below is my code of initialize apolloclient object\r\n\r\n```\r\nlet apollo = ApolloClient(url: URL(string: graphQLEndpoint)!)\r\napollo.cacheKeyForObject = { $0[\"id\"] }\r\n```\r\nBut every time it fetch from server not from cache. I am stuck in this issue but no luck found.\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/apollographql/apollo-ios/issues/comments/372896791","html_url":"https://github.com/apollographql/apollo-ios/issues/226#issuecomment-372896791","issue_url":"https://api.github.com/repos/apollographql/apollo-ios/issues/226","id":372896791,"user":{"login":"dikenshah1212","id":35653171,"avatar_url":"https://avatars1.githubusercontent.com/u/35653171?v=4","gravatar_id":"","url":"https://api.github.com/users/dikenshah1212","html_url":"https://github.com/dikenshah1212","followers_url":"https://api.github.com/users/dikenshah1212/followers","following_url":"https://api.github.com/users/dikenshah1212/following{/other_user}","gists_url":"https://api.github.com/users/dikenshah1212/gists{/gist_id}","starred_url":"https://api.github.com/users/dikenshah1212/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dikenshah1212/subscriptions","organizations_url":"https://api.github.com/users/dikenshah1212/orgs","repos_url":"https://api.github.com/users/dikenshah1212/repos","events_url":"https://api.github.com/users/dikenshah1212/events{/privacy}","received_events_url":"https://api.github.com/users/dikenshah1212/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T03:54:39Z","updated_at":"2018-03-14T03:54:39Z","author_association":"NONE","body":"I have tried with below code but got same result\r\n\r\n```\r\nlet store = ApolloStore(cache: InMemoryNormalizedCache())\r\n        store.cacheKeyForObject = { $0[\"id\"] }\r\n        let configuration = URLSessionConfiguration.default\r\n        \r\n        let apollo = ApolloClient(networkTransport: HTTPNetworkTransport(url: URL(string: graphQLEndpoint)!, configuration: configuration), store: store)\r\n```\r\nPlease let me know if I missed something.\r\n"}}
{"actor":{"display_login":"dikenshah1212"}}