{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-server/issues/103","repository_url":"https://api.github.com/repos/apollostack/apollo-server","labels_url":"https://api.github.com/repos/apollostack/apollo-server/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-server/issues/103/comments","events_url":"https://api.github.com/repos/apollostack/apollo-server/issues/103/events","html_url":"https://github.com/apollostack/apollo-server/issues/103","id":172293142,"number":103,"title":"Empty response on graphql request","user":{"login":"JeroenBe","id":6019254,"avatar_url":"https://avatars.githubusercontent.com/u/6019254?v=3","gravatar_id":"","url":"https://api.github.com/users/JeroenBe","html_url":"https://github.com/JeroenBe","followers_url":"https://api.github.com/users/JeroenBe/followers","following_url":"https://api.github.com/users/JeroenBe/following{/other_user}","gists_url":"https://api.github.com/users/JeroenBe/gists{/gist_id}","starred_url":"https://api.github.com/users/JeroenBe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeroenBe/subscriptions","organizations_url":"https://api.github.com/users/JeroenBe/orgs","repos_url":"https://api.github.com/users/JeroenBe/repos","events_url":"https://api.github.com/users/JeroenBe/events{/privacy}","received_events_url":"https://api.github.com/users/JeroenBe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-08-20T22:02:42Z","updated_at":"2016-08-22T04:12:38Z","closed_at":null,"body":"# Empty response on graphql request\r\nWhen sending a graphql `POST` request to the `apollo-server`, I receive nothing but an empty response. \r\n\r\n## Context\r\nSince this is my first ever project using Apollo (trying to set it up with Meteor, React, apollo-client and apollo-server using express), I'm just trying to connect a front end with the Fortunecookie api.\r\n\r\nThis is what I figured out so far:\r\n* The first sign of an error is the following: `\"Can't find field fortuneCookie on object (ROOT_QUERY) {}.↵Perhaps you want to use the 'returnPartialData' option?\"`. When I went looking for this in the Redux Devtool, I found my `query` as such: \r\n``` JSON\r\nquery: {\r\n    id: \"ROOT_QUERY\",\r\n    typeName: \"Query\",\r\n    selectionSet: { ... }\r\n}\r\n```\r\n* Next I went looking for the actual request I sent to the server:\r\n```\r\n{\"query\":\"{\\n  fortuneCookie {\\n    fortune\\n  }\\n}\\n\",\"operationName\":\"\"}\r\n```\r\nWhich gave nothing in response.\r\n\r\n## Setup\r\nSince the task I want to complete is fairly simple, my setup is too. The query I want to execute runs perfectly fine on GraphiQL, which leads me to believe my server is running as it should. \r\n\r\n### ApolloProvider\r\n```JavaScript\r\nimport React, {Component} from 'react'\r\n\r\nimport { ApolloProvider } from 'react-apollo'\r\nimport client from '/imports/api/apollo/client/client'\r\n\r\nexport default MainLayout = ({content}) => {\r\n    return (\r\n        <main id=\"MainLayout\">\r\n            <ApolloProvider client={client}>\r\n                {content}\r\n            </ApolloProvider>\r\n        </main>\r\n    )\r\n}\r\n```\r\n\r\n### Child Component\r\nThe `{content}` child set in the `<ApolloProvider />` is the `<TestComponent />` displayed below. This is set using kadira's `FlowRouter` and `react-mounter`, nothing special there. \r\n\r\n```JavaScript\r\nimport React, {Component} from 'react'\r\nimport {graphql} from 'react-apollo'\r\nimport gql from 'graphql-tag'\r\nconst TestComponentWithoutData =  class TestComponentWithoutData extends Component {\r\n    render() {\r\n        const {loading, data} = this.props.data\r\n        return (\r\n            <div className=\"TestComponent\">\r\n                { loading? 'loading...' : data.fortuneCookie}\r\n            </div>\r\n        )\r\n    }\r\n}\r\n\r\nconst FORTUNE = gql`{\r\n  fortuneCookie{fortune}\r\n}`\r\n\r\nconst withFortune = graphql(FORTUNE)\r\nexport default TestComponent = withFortune(TestComponentWithoutData)\r\n```\r\n\r\n## Extra Screenshots\r\nDuring a conversation on the apollo slack channel, I took some screenshots. They might provide some extra insights. \r\nThe `ApolloClient` object:\r\n<img width=\"1000\" alt=\"screen shot 2016-08-20 at 23 18 42\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834094/1279fc6e-6732-11e6-8502-0ef234a0f044.png\">\r\n\r\nThe `HTTP request` (response is empty):\r\n<img width=\"1177\" alt=\"screen shot 2016-08-20 at 23 30 37\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834099/2a75f944-6732-11e6-90de-9b232a435764.png\">\r\n<img width=\"516\" alt=\"screen shot 2016-08-20 at 23 31 20\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834100/2a9e1262-6732-11e6-82ef-f2ec2cf79916.png\">\r\n<img width=\"461\" alt=\"screen shot 2016-08-20 at 23 34 03\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834110/62b76a04-6732-11e6-8dec-a5b7323c3167.png\">\r\n\r\nFirst an `APOLLO_QUERY_INIT` action is stored:\r\n<img width=\"556\" alt=\"screen shot 2016-08-20 at 23 33 00\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834104/426882b0-6732-11e6-9f51-b2c8a29e6295.png\">\r\n\r\nNext an `APOLLO_QUERY_ERROR` action:\r\n<img width=\"493\" alt=\"screen shot 2016-08-20 at 23 32 38\" src=\"https://cloud.githubusercontent.com/assets/6019254/17834107/5b698da4-6732-11e6-9923-48544cf28df7.png\">\r\n\r\n\r\nI hope I provided enough information. Please bare with me that chances are my setup is just wrong and there is nothing funky going on with the apollo stack. This is my first project after all.\r\n\r\nEDIT: I realise I said my server seems to be running fine, but because there isn't any response returned from my request I thought this issue belonged in the `apollo-server` repo.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-server/issues/comments/241311493","html_url":"https://github.com/apollostack/apollo-server/issues/103#issuecomment-241311493","issue_url":"https://api.github.com/repos/apollostack/apollo-server/issues/103","id":241311493,"user":{"login":"Tallyb","id":7386255,"avatar_url":"https://avatars.githubusercontent.com/u/7386255?v=3","gravatar_id":"","url":"https://api.github.com/users/Tallyb","html_url":"https://github.com/Tallyb","followers_url":"https://api.github.com/users/Tallyb/followers","following_url":"https://api.github.com/users/Tallyb/following{/other_user}","gists_url":"https://api.github.com/users/Tallyb/gists{/gist_id}","starred_url":"https://api.github.com/users/Tallyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tallyb/subscriptions","organizations_url":"https://api.github.com/users/Tallyb/orgs","repos_url":"https://api.github.com/users/Tallyb/repos","events_url":"https://api.github.com/users/Tallyb/events{/privacy}","received_events_url":"https://api.github.com/users/Tallyb/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T04:12:38Z","updated_at":"2016-08-22T04:12:38Z","body":"ok - here is what I did: \r\non client.js: \r\n\r\n```\r\nexport default client = new ApolloClient({\r\n\tnetworkInterface: createNetworkInterface('//localhost:4000/graphql', {\r\n    credentials: 'same-origin',\r\n\t}), \r\n\tshouldBatch: false\r\n\t}); \r\n```\r\n\r\nThen I added cors support as described in the docs: \r\nhttp://docs.apollostack.com/apollo-server/tools.html#corsSupport\r\n\r\nso server js now has: \r\n```\r\nimport cors from 'cors';\r\n\r\nconst app = express().use('*', cors());\r\n```\r\n\r\nNeed also `npm install cors` of course (pun-intended)\r\n"}}
{"actor":{"display_login":"Tallyb"}}