{"action":"opened","issue":{"url":"https://api.github.com/repos/apollographql/apollo-client/issues/4107","repository_url":"https://api.github.com/repos/apollographql/apollo-client","labels_url":"https://api.github.com/repos/apollographql/apollo-client/issues/4107/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-client/issues/4107/comments","events_url":"https://api.github.com/repos/apollographql/apollo-client/issues/4107/events","html_url":"https://github.com/apollographql/apollo-client/issues/4107","id":378174703,"node_id":"MDU6SXNzdWUzNzgxNzQ3MDM=","number":4107,"title":"Variable is just empty object","user":{"login":"rico345100","id":10347098,"node_id":"MDQ6VXNlcjEwMzQ3MDk4","avatar_url":"https://avatars0.githubusercontent.com/u/10347098?v=4","gravatar_id":"","url":"https://api.github.com/users/rico345100","html_url":"https://github.com/rico345100","followers_url":"https://api.github.com/users/rico345100/followers","following_url":"https://api.github.com/users/rico345100/following{/other_user}","gists_url":"https://api.github.com/users/rico345100/gists{/gist_id}","starred_url":"https://api.github.com/users/rico345100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rico345100/subscriptions","organizations_url":"https://api.github.com/users/rico345100/orgs","repos_url":"https://api.github.com/users/rico345100/repos","events_url":"https://api.github.com/users/rico345100/events{/privacy}","received_events_url":"https://api.github.com/users/rico345100/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-07T07:44:43Z","updated_at":"2018-11-07T07:44:43Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  Thanks for filing an issue on Apollo Client!\r\n\r\n  Please make sure that you include the following information to ensure that your issue is actionable.\r\n\r\n  If you don't follow the template, your issue may end up being closed without anyone looking at it carefully, because it is not actionable for us without the information in this template.\r\n\r\n  **PLEASE NOTE:** Feature requests and non-bug related discussions are no longer managed in this repo. Feature requests should be opened in https://github.com/apollographql/apollo-feature-requests.\r\n-->\r\n\r\n**Intended outcome:**\r\nHere's my schema.\r\n\r\n```gql\r\ntype Query {\r\n  paymentList(filter: String, skip: Int, pageSize: Int): PaymentList\r\n}\r\n```\r\n\r\nAnd this is the query:\r\n\r\n```javascript\r\nexport const getPayments = gql`\r\n  query Transactions {\r\n    paymentList {\r\n      total\r\n      list {\r\n        id\r\n        ... and other fields ...\r\n      }\r\n    }\r\n  }\r\n```\r\n\r\nSending variables from 'https://localhost:3030/graphql' works fine, however sending request from apollo-client, apollo-server doesn't have any value from it:\r\n\r\n```javascript\r\n// Client Code\r\nconst result: ApolloQueryResult<any> = await apolloClient.query({\r\n    query: getPayments,\r\n    variables: {\r\n        filter: '',\r\n        skip,\r\n        pageSize,\r\n    },\r\n});\r\n\r\nreturn result.data.paymentList;\r\n```\r\n\r\n```javascript\r\n// Server Code\r\nexport async function paymentList(parent, args, context, info): Promise<PaginatedQueryResult<PaymentEntity> | Error> {\r\n  const paymentRepo = await getRepository(PaymentEntity);\r\n  const { filter, skip } = args;\r\n  let { pageSize } = args;\r\n\r\n  if(typeof pageSize === 'undefined' || pageSize === 0) {\r\n    pageSize = defaultOptions.pageSize;\r\n  }\r\n\r\n  const [payments, count] = await paymentRepo.findAndCount({\r\n    skip,\r\n    take: pageSize\r\n  });\r\n\r\n  console.log(args);   // Expected variables in here, but it's just {}\r\n\r\n  return {\r\n    total: count,\r\n    list: payments\r\n  };\r\n}\r\n```\r\n\r\n**Actual outcome:**\r\n<!--\r\nA description of what actually happened, including a screenshot or copy-paste of any related error messages, logs, or other output that might be related. Places to look for information include your browser console, server console, and network logs. Please avoid non-specific phrases like “didn’t work” or “broke”.\r\n-->\r\n\r\nHere's the request payload inspected from Chrome:\r\n\r\n```text\r\n{operationName: \"Transactions\", variables: {filter: \"\", skip: 0, pageSize: 10},…}\r\n```\r\n\r\nSo the variable is actually sent, but here's the result on console(server);\r\n\r\n```bash\r\n::ffff:127.0.0.1 - - [07/Nov/2018:07:33:37 +0000] \"OPTIONS /graphql HTTP/1.1\" 204 -\r\n{}\r\n::ffff:127.0.0.1 - - [07/Nov/2018:07:33:37 +0000] \"POST /graphql HTTP/1.1\" 200 3424\r\n```\r\n\r\nBut using :3030/graphql works:\r\n\r\n<img width=\"1680\" alt=\"2018-11-07 4 40 25\" src=\"https://user-images.githubusercontent.com/10347098/48117238-eab7d000-e2ab-11e8-95cc-2907a05c4152.png\">\r\n\r\n```bash\r\n{ filter: 'Hello Filter', skip: 90, pageSize: 10 }\r\n::ffff:127.0.0.1 - - [07/Nov/2018:07:41:14 +0000] \"POST /graphql HTTP/1.1\" 200 1607\r\n```\r\n\r\n**How to reproduce the issue:**\r\n<!--\r\nIf possible, please create a reproduction using https://github.com/apollographql/react-apollo-error-template and link to it here. If you prefer an in-browser way to create reproduction, try: https://codesandbox.io/s/github/apollographql/react-apollo-error-template\r\n\r\nInstructions for how the issue can be reproduced by a maintainer or contributor. Be as specific as possible, and only mention what is necessary to reproduce the bug. If possible, try to isolate the exact circumstances in which the bug occurs and avoid speculation over what the cause might be.\r\n-->\r\n\r\nHere's the full client source code I'm using.\r\n\r\n```javascript\r\n/* @flow */\r\nimport { ApolloClient } from 'apollo-client';\r\nimport { getMainDefinition } from 'apollo-utilities';\r\nimport { ApolloLink, split } from 'apollo-link';\r\nimport { WebSocketLink } from 'apollo-link-ws';\r\nimport { createHttpLink } from 'apollo-link-http';\r\nimport { InMemoryCache } from 'apollo-cache-inmemory';\r\n\r\nimport config from '../config';\r\n\r\nconst BASE_URI = `${config.apiHost}${config.apiPort ? `:${config.apiPort}` : ''}`;\r\n\r\nconst GRAPHQL_ENDPOINT = `${config.apiScheme}://${BASE_URI}/graphql`;\r\nconst GRAPHQL_SUBSCRIPTIONS_ENDPOINT = `${config.graphqlWSScheme}://${BASE_URI}/graphql`;\r\n\r\n// Create an http link:\r\nconst httpLink = createHttpLink({\r\n  uri: GRAPHQL_ENDPOINT,\r\n  credentials: 'include'\r\n});\r\n\r\n// Create a WebSocket link:\r\nconst wsLink = new WebSocketLink({\r\n  uri: GRAPHQL_SUBSCRIPTIONS_ENDPOINT,\r\n  options: {\r\n    reconnect: true\r\n  }\r\n});\r\n\r\nconst terminatingLink = split(\r\n  // split based on operation type\r\n  ({ query }) => {\r\n    const { kind, operation } = getMainDefinition(query);\r\n    return kind === 'OperationDefinition' && operation === 'subscription';\r\n  },\r\n  wsLink,\r\n  httpLink\r\n);\r\n\r\nconst link = ApolloLink.from([terminatingLink]);\r\n\r\nconst cache = new InMemoryCache();\r\n\r\nconst apolloClient = new ApolloClient({\r\n  link,\r\n  cache,\r\n  defaultOptions: {\r\n    watchQuery: {\r\n      fetchPolicy: 'network-only',\r\n      errorPolicy: 'ignore'\r\n    },\r\n    query: {\r\n      fetchPolicy: 'network-only',\r\n      errorPolicy: 'all'\r\n    }\r\n  }\r\n});\r\n\r\nexport default apolloClient;\r\n```\r\n\r\nAnd this is how I'm using it:\r\n\r\n```javascript\r\nasync getData(pageNum: number, pageSize: number): Promise<PaginatedQueryResult<PaymentEntity> | Error> {\r\n    const skip = (pageNum - 1) * pageSize;\r\n    \r\n    const result: ApolloQueryResult<any> = await apolloClient.query({\r\n        query: getPayments,\r\n        variables: {\r\n        filter: '',\r\n        skip,\r\n        pageSize,\r\n        },\r\n    });\r\n\r\n    return result.data.paymentList;\r\n}\r\n```\r\n\r\n**Versions**\r\n<!--\r\nRun the following command in your project directory, and paste its (automatically copied to clipboard) results here:\r\n\r\n`npx envinfo@latest --preset apollo --clipboard`\r\n-->\r\n\r\n```bash\r\nSystem:\r\n    OS: macOS High Sierra 10.13.6\r\n  Binaries:\r\n    Node: 8.12.0 - /usr/local/bin/node\r\n    Yarn: 1.10.1 - /usr/local/bin/yarn\r\n    npm: 6.4.1 - /usr/local/bin/npm\r\n  Browsers:\r\n    Chrome: 70.0.3538.77\r\n    Firefox: 63.0.1\r\n    Safari: 12.0.1\r\n  npmPackages:\r\n    apollo-server: ^2.0.7 => 2.1.0 \r\n    apollo-server-koa: ^2.0.6 => 2.1.0 \r\n```"}}
{"actor":{"display_login":"rico345100"}}