Prisma1: Subscription Issue with new models or fields

Created on 5 Dec 2017  Â·  10Comments  Â·  Source: prisma/prisma1

Currently anything newly created does not correctly work with subscriptions, field or model.

Current behavior
Subscription On new Model:

  subscription allEvents {
    Event(filter:{
      mutation_in: [DELETED, UPDATED, CREATED]
    }) {
      mutation
      node {
        id
        title
        image
        description
        date
        ctaText
        ctaButton
        ctaLink
        createdAt
        updatedAt
      }
      previousValues {
        id
      }
    }
  }

----------------------------------------Result----------------------------------------------
{
  "data": null,
  "error": [
    {
      "message": "The provided query doesn't include any known model name. Please check for the latest subscriptions API."
    }
  ]
}

Although the model does actually exist

type Event @model {
  id: ID! @isUnique
  title: String!
  image: String
  description: String!
  date: DateTime!
  ctaText: String
  ctaButton: String
  ctaLink: String
  createdAt: DateTime!
  updatedAt: DateTime!
}

Subscription on existing model with new fields

  • source: Source (Enum)
  • ctaText: String
  • ctaButton: String
  • ctaLink: String
  subscription BlogPostSingleSub {
    BlogPost(filter:{
      mutation_in: [DELETED, UPDATED, CREATED]
    }) {
      mutation
      node {
        id
        source
        ctaText
        ctaButton
        ctaLink
      }
    }
  }

----------------------------------------Result----------------------------------------------
{
  "data": null,
  "error": [
    {
      "message": "Cannot query field 'source' on type 'BlogPost'. (line 8, column 9):\n        source\n        ^"
    }
  ]
}

if you remove source from the query, it will then complain about ctaText and so on... Until all newly added fields are gone.

Reproduction
Create new model, and add fields to existing models, and attempt to subscribe to them as shown above

Expected behavior?
For there to be no errors and the subscriptions to return the data requested

Any further questions about anything please feel free to ask. I noticed this issue around mid-day UK time. Strangely enough I created a new project in the morning, however once around mid-day anything new I added to it did not work with subscriptions. Can confirm this does not only effect the project I created today however, as older projects I add anything new to show the same behaviour

aresubscriptions bu2-confirmed

Most helpful comment

We're working on a fix and will release that soon 🙂

All 10 comments

I encountered the same issue. I added 2 new types to my enum yesterday and now everything I create with those new types, are not picked up by the subscription I set in place.

The Fields and models I mentioned yesterday now work fine with subscriptions. However I've added more new fields today, and am getting the same issues as before. Appears that new models and fields are taking a very long time to propagate to the subscription endpoints.

Still doesnt work for me... Every new field I add does not get picked up, it's been 2 days already.

Thanks for reporting this issue.

The subscriptions service log shows the following error when the schema is invalidated:

[31m[SubscriptionsManagerForProject] Received unknown message: Message(cjatgtvnp0zsp0140wja4vq9g,cjatgtvnp0zsp0140wja4vq9g)

I have the same issue and spent quite a few hours ensuring that it is nothin on my side. In the end I created a new (console-)project (cjaz9l1n61lhe010715oa1zso). Added

type Version @model {
  createdAt: DateTime!
  id: ID! @isUnique
  lockscreenUrl: String
  updatedAt: DateTime!
  version: String! @isUnique
}

tested subscribing to it and it worked fine. I then changed the type to:

type Version @model {
  createdAt: DateTime!
  id: ID! @isUnique
  lockscreenUrl: String
  updatedAt: DateTime!
  version: String! @isUnique
  deviceLogin: Boolean! @defaultValue(value: false)
}

i.e. added deviceLogin: Boolean! @defaultValue(value: false) and now any subscription containing the new deviceLogin field fails with the same error as if the field would not exist at all. Minimal reproduction code:

const ws = new WebSocket(
  "wss://subscriptions.graph.cool/v1/cjaz9l1n61lhe010715oa1zso",
  "graphql-subscriptions"
);
ws.onerror = console.log;
ws.onmessage = evt => console.log(evt.data);
ws.onclose = console.log;
setTimeout(() => {
  ws.send(JSON.stringify({ type: "init" }));
}, 1000);
setTimeout(() => {
  ws.send(
    JSON.stringify({
      type: "subscription_start",
      query:
        "\nsubscription($version: String!) {\n  Version(\n    filter: { mutation_in: [CREATED, UPDATED], node: { version: $version } }\n  ) {\n    node {\n      deviceLogin\n      lockscreenUrl\n    }\n  }\n}\n",
      variables: { version: "versionID" },
      id: "1"
    })
  );
}, 2000);
setTimeout(() => {
  ws.close()
}, 3000);

// Result: {"id":"1","payload":{"errors":[{"message":"Cannot query field 'deviceLogin' on type 'Version'. (line 7, column 7):\n      deviceLogin\n      ^"}]},"type":"subscription_fail"}

Any help would be really appreciated. As I said, this is such a big blocker, that I couldn't believe that it's an actual bug - I really tried hard to find the mistake on my side... 😅

Any workaround for this issue? It keeps us from moving to production…

We're working on a fix and will release that soon 🙂

We got same problem when adding new models or fields. Please fix this ASAP

We deployed a fix, thanks for your help everyone 🙂

Can confirm it works now. I'll remove the project I set up for the reproduction. So later readers will find it doesn't work, but not because of that bug anymore.

Was this page helpful?
0 / 5 - 0 ratings