{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/167","repository_url":"https://api.github.com/repos/apollographql/apollo-link-rest","labels_url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/167/comments","events_url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/167/events","html_url":"https://github.com/apollographql/apollo-link-rest/issues/167","id":374602459,"node_id":"MDU6SXNzdWUzNzQ2MDI0NTk=","number":167,"title":"Arbitrary context value not making it to query","user":{"login":"robbywashere","id":1592012,"node_id":"MDQ6VXNlcjE1OTIwMTI=","avatar_url":"https://avatars0.githubusercontent.com/u/1592012?v=4","gravatar_id":"","url":"https://api.github.com/users/robbywashere","html_url":"https://github.com/robbywashere","followers_url":"https://api.github.com/users/robbywashere/followers","following_url":"https://api.github.com/users/robbywashere/following{/other_user}","gists_url":"https://api.github.com/users/robbywashere/gists{/gist_id}","starred_url":"https://api.github.com/users/robbywashere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbywashere/subscriptions","organizations_url":"https://api.github.com/users/robbywashere/orgs","repos_url":"https://api.github.com/users/robbywashere/repos","events_url":"https://api.github.com/users/robbywashere/events{/privacy}","received_events_url":"https://api.github.com/users/robbywashere/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-27T03:48:31Z","updated_at":"2018-10-27T20:02:51Z","closed_at":null,"author_association":"NONE","body":"<!--**Issue Labels**\r\n\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\r\nI am attempting to store an api key in the context so I may use it in the query. The api I am using requires the api key to be used as a query parameter. So here what I am doing.\r\n\r\n```typescript\r\n\r\nconst withToken = setContext(() => ({\r\n    apiKey: \"1234567890abcdefg\"\r\n}));\r\n\r\nconst restLink = new RestLink({\r\n  uri: \"https://behance.net/v2/\"\r\n});\r\n\r\nconst client = new ApolloClient({\r\n  link: withToken.concat(restLink),\r\n  cache: new InMemoryCache()\r\n});\r\n\r\n```\r\n\r\nThis is what the query looks like:\r\n\r\n```typescript\r\nexport const UserSearchQuery = gql`\r\n  query UserSearch($q: String!) {\r\n    user(q: $q)\r\n      @rest(type: \"User\", path: \"users?{args}&api_key={context.apiKey}\") {\r\n      ...UserFragment\r\n      followers @rest(path: \"/users?{exportVariables.id}\", type: \"[User]\") {\r\n        ...UserFragment\r\n      }\r\n    }\r\n  }\r\n`;\r\n\r\n```\r\nHere is the HOC hook-up\r\n\r\n```typescript\r\nexport const UserSearchResult = graphql<\r\n  InputProps,\r\n  Response,\r\n  Variables,\r\n  UserChildProps\r\n>(UserSearchQuery, {\r\n  options: ({ q }) => {\r\n    return {\r\n      variables: { q }\r\n    };\r\n  }\r\n})(UsersResult);\r\n```\r\n\r\nand this is the final url that comes up `https://behance.net/v2/users?q=user&api_key=undefined`\r\n\r\nnotice the undefined?\r\n\r\nThe docs indicate this is possible, but it is not working, so I am filing this as a bug."},"comment":{"url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/comments/433651041","html_url":"https://github.com/apollographql/apollo-link-rest/issues/167#issuecomment-433651041","issue_url":"https://api.github.com/repos/apollographql/apollo-link-rest/issues/167","id":433651041,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzY1MTA0MQ==","user":{"login":"fbartho","id":209712,"node_id":"MDQ6VXNlcjIwOTcxMg==","avatar_url":"https://avatars2.githubusercontent.com/u/209712?v=4","gravatar_id":"","url":"https://api.github.com/users/fbartho","html_url":"https://github.com/fbartho","followers_url":"https://api.github.com/users/fbartho/followers","following_url":"https://api.github.com/users/fbartho/following{/other_user}","gists_url":"https://api.github.com/users/fbartho/gists{/gist_id}","starred_url":"https://api.github.com/users/fbartho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fbartho/subscriptions","organizations_url":"https://api.github.com/users/fbartho/orgs","repos_url":"https://api.github.com/users/fbartho/repos","events_url":"https://api.github.com/users/fbartho/events{/privacy}","received_events_url":"https://api.github.com/users/fbartho/received_events","type":"User","site_admin":false},"created_at":"2018-10-27T20:02:51Z","updated_at":"2018-10-27T20:02:51Z","author_association":"COLLABORATOR","body":"One open problem is that when this value changes, Apollo doesn’t know the context value should be part of the cache key for this query. \r\n\r\nI think that’s okay for api tokens, but ultimately that’s what aborted my code patterns that we’re going to make heavier use of context.\r\n\r\nI think in ApolloClient 3, they’ll have more hooks so we could possibly fix this. For now, however, we can’t :-("}}
{"actor":{"display_login":"fbartho"}}