Does anyone know how to get all relations for a fi...
# random
o
Does anyone know how to get all relations for a field in previousValues in a subscription query? I have a Server side subscription function that is meant to create a notification when things change on a
post
, for that it needs to compare the new values against the old to specify what exactly changed. It works well for scalar fields, but having trouble with relations. (By the way, am aware that the function itself won’t trigger from a change in the relation, will address that with the Dummy field workaround) What I have now:
Copy code
subscription {
  Post(filter: {
    mutation_in: [CREATED, UPDATED, DELETED]
  }) {
    updatedFields
    node {
      id
      name
      admins {id}
    }
    previousValues {
      id
      name
      admins: id 
    }
  }
}
So far
updatedFields
will give all admins on the post, but
previousValues
doesn’t and will not accept the same format. It does give the id of 1 admin when formatted as above.
p
Hey @olaf, this is currently a limitation of the API. I ran into the same issue the other day
And the issue I opened (which has similar description to yours): https://github.com/graphcool/api-bugs/issues/220 Might be worth posting something in the forum / feature-requests repo so this feature can get bumped up
o
Ah I see, figured it might be something like it but was hoping I was doing it wrong haha. Thanks @pcooney10 will post in the issue