fanout / apollo-serverless-demo

Serverless GraphQL subscriptions
https://apollo.fanoutapp.com/
MIT License
107 stars 5 forks source link

Not working. Is this still a thing? Trying to do apollo subscriptions with serverless nextjs. #23

Open bbourn opened 4 years ago

bbourn commented 4 years ago
Command: FanoutGraphqlApolloConfig: subscriptions will be disabled. 
options: {
  grip: { url: 'http://localhost:5561', getGripChannel: [Function] },
  pubsub: PubSub {
    ee: EventEmitter {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined
    },
    subscriptions: {},
    subIdCounter: 0
  },
  subscriptions: false,
  tables: {
    connections: {
      delete: [Function: delete],
      get: [Function: get],
      insert: [Function: insert],
      scan: [Function: scan],
      update: [Function: update]
    },
    notes: {
      delete: [Function: delete],
      get: [Function: get],
      insert: [Function: insert],
      scan: [Function: scan],
      update: [Function: update]
    },
    pubSubSubscriptions: {
      delete: [Function: delete],
      get: [Function: get],
      insert: [Function: insert],
      scan: [Function: scan],
      update: [Function: update]
    }
  }
}
harmony7 commented 4 years ago

I'd like to ask for clarification: Are you trying to run this as an API in Next.js, or deploy this as a serverless function on ZEIT Now, which is a server platform by the same authors? We have directions in the README that discuss how to deploy the example to ZEIT Now.

From the logs above it looks like you are trying to access the backend directly after deploying it. This demo is meant to be fronted with a Fanout proxy, so you need a Fanout account. Once logged in, you can set up a domain so that its Origin points to the serverless function that you have deployed to the cloud.

Additionally, you must set the GRIP_URL environment variable to the publishing endpoint, including your realm ID and realm Key, which are available from the Fanout Control Panel.

You set the environment variable by adding it to now.json (be sure to replace {realm-id} and {realm-key} with your actual values):

  "env": {
    "GRIP_URL": "https://api.fanout.io/realm/{realm-id}?iss={realm-id}&key=base64:{realm-key}"
  }

We are updating the README file with these steps to clarify.

If you need help deploying as an API in Next.js, then we may look in to providing an example.