been away from graphcool for a bit - can you guys ...
# prisma-whats-new
m
been away from graphcool for a bit - can you guys remind me what the breaking changes are? mutation callbacks and permissions?
n
@monkeybonkey Indeed, Functions and Permissions, as well as a CLI, were the latest major additions to the platform. You can read about all of them on our blog: https://www.graph.cool/blog/ Note that we'll deprecate Mutation Callbacks soon since they're replaced with the more powerful concept of Server-side Subscriptions.
If you want to have an overview of all major platform functionality that's available atm, check out this article: https://www.graph.cool/docs/tutorials/graphcool-features-overview-ped6wohw0o/ 🙂
n
@monkeybonkey breaking changes to permission queries only affects queries that have been defined during the permission query beta. mutation callbacks will be deprecated on 6th of august, until then they need to be migrated to SSS functions.
PQ following the old API will be deprecated in 4 days on 25th of June.
m
how can I tell if I'm using the old or new permission queries?
n
The old PQ API was mirroring queries in the Simple API. The new PQ API features new queries
SomeXExists
that return a boolean.
m
so functions and subscriptions are 2 different things right?
n
correct
one type of function that you can define, is called server-side subscriptions though, because it follows the same "workflow" as typical subscriptions
server-side subscriptions are basically mutation callbacks on steroids 😛
m
so does that mean I need to set up my server to watch the collections and trigger my own webhooks?
oh I see - I can create a server side function that is a subscription…?
n
m
so I'm running into the issue again where the docs screen obscures the subscription query
if I hit the "docs" tab on the function editor query
n
You should be able to drag and drop it to the right
OR open the fullscreen mode and adjust the slider there
m
ah ok
that's a bit unclear
the thin green line makes it hard to realize that it's a draggable area
n
yea that got me confused as well. we noted it down here, but will probably fix this as part of a bigger UI iteration: https://github.com/graphcool/ui-feedback/issues/13
m
when I run the example test-run in the function editor
are those fake results?
and will the json field types be returned as strings or as json?
e.g. the sample run gives me:
"players": [ { "id": "cj473who100ha3k5w30ialqg2", "deviceTokens": "<Json>" }, { "id": "cj473who100hb3k5wj1v2qnpz", "deviceTokens": "<Json>" } ] }, "message": "string", "user": { "id": "cj473who100hc3k5w8m4ea5da", "username": "string" }
n
on the left side you can click "Example event" to modify the example input
did you try
JSON.parse(players[0].deviceTokens)
?
m
the docs say that callbacks are not supported in functions - so does it expect me to return a promise for async functions?
n
yes exactly
if you want to use a package with a callback API, you need to wrap that callback thing with a promise and
resolve
or
reject
from within the callback
m
I have the following but it doesn't seem to be resolving promise: module.exports = function (event) { console.log('Received event') const msg = event.data.GroupMessage.node; if (msg) { console.log('sending push msg'); send(msg).then(function (results){ console.log(results); return results; }) .catch(function (err) { console.log('error in sending push'); return err; }); } else { console.log('no message') } }
I don't get the results or an error … the send function is a Promise.all of a collection of request-promises
n
what is
request-promises
?
try
return send(msg)...
instead of
send(msg)...
m
request-promise is a promisified version of the request library
adding return send … did it
n
👍