raylight
raylight

Reputation: 727

How can I allow subscriptions on RedwoodJS?

Let's say I create a new RedwoodJS project from scratch with

yarn create redwood-app my-project

In this step, I've chosen to create a Typescript project... Then I setup this project to use both the experimental server and realtime features:

yarn rw exp setup-server-file
yarn rw exp setup-realtime

And finally, I create a new subscription:

yarn rw exp generate-realtime mySub

enter image description here

So far it seems to be working fine and I get the following result:

enter image description here

However, if I now start this project with yarn rw dev and go to the graphiql endpoint on http://localhost:8911/graphql, the suggested subscription query on my code doesn't work, if I try to run

subscription ListenToMysubChannel {
  listenToMysubChannel(id: "1") {
    body
    from
  }
}

I get the error:

{
  "errors": [
    {
      "message": "GraphQL operation type \"subscription\" is not allowed.",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ]
    }
  ]
}

What am I missing in this procedure? Do I need to manually edit any file in order to activate the GraphQL subscriptions?

Upvotes: 0

Views: 100

Answers (1)

cheese-toast
cheese-toast

Reputation: 1

Bit of a stab but maybe you've missed this step: https://redwoodjs.com/docs/realtime#graphql-configuration

Specifically: uncommenting the 'realtime' at the end of api/server.ts.

Upvotes: 0

Related Questions