Run Function is not triggered - twilio-functions

I have created a studio flow in that I am using a function, But it looks like it is not triggered when the flow is executed.
I am using the node and Axios in the function.

Related

Running method on every call using express-graphql

I'm using express-graqphl and was wondering if there is any concept of running a function before each graphql endpoint is executed? I'd like to have this for things like validating JWTs and other things. I realize we could use express for this, e.g.
app.use('/graphql`, doChecks);
but I'd like for the graphql handler to throw an error so it'll be inside the errors: [] list in the results giving the client a consistent experience with the api. Is there any direct support for this in the package?
The context function is executed before every request. If you're using Apollo v4+ then here are the docs
The context function is most often used to manage auth, including reading and validation of security tokens.

Apollo refetchQueries unit test with vue testing library

I am new to graphql and apollo. I have a useMutation query which on completion perform a refetchQueries operation of 2 other queries. How to write a unit for refetchQueries specific, so that if I remove the refetchQueries code my test should fail.
I am using vitest, vite, vue3, apollo, graphql, vue-testing-library and msw for mocking.
Note: The queries which I want to perform in refetchQueries will reflect data change in some other component and will not be visible in the current component, so the assertion which I am looking something like this:
expect(getQuery1).toHaveBeenCalled()
Is it possible to perform this assertion?

Apollo - update() method getting called twice, both times with optimistic/fake data

I'm completely stuck on an Apollo problem, for which I've opened a GitHub issue and had zero response on.
I'm calling an Apollo mutation, using optimisticResponse. The way it's supposed to work, as I understand it, is that update() gets called twice: first with the optimistic data, then again with the actual data coming in from the network.
But for some reason, my code is not working like this. I'm getting two update() calls, both with the optimistic data.
Here's a repo that demonstrates this behavior: https://github.com/ffxsam/apollo-update-bug
yarn && yarn dev
Open in browser, open console
Enter some text and hit enter
Repeat above
Notice the error in the console about duplicate keys. This is happening because the temporary ID "??" is not being replaced with the real UUID
(optional) You can open Vue DevTools if available and inspect the data to see it's incorrect
I was doing some digging and I think I found the source of the problem.
Unfortunately, I don't have a solution.
In short, the problem might be with a network link called OfflineLink that is used by aws-appsync.
Explanation
aws-appsync has an ApolloLink called OfflineLink that intervenes with the request function.
What happens is something like this:
you call $apollo.mutate(...)
ApolloClient.QueryManager initializes the mutation that triggers your update the first time with the optimistic response. That is happening inside ApolloClient data store, markMutationInit calls markMutationResult that calls your update.
The graphql operation executes and reaches the OfflineLink in the network chain.
OfflineLink creates a new observer and dispatches the mutation info as an action.
The next line of OfflineLink calls the observer's next function with the optimisticResponse as if it was the execution result!
This triggers your update the second time with the result which is actually the optimisticResponse.
OfflineLink calls the observer's complete which resolves your promise.
console.log('done!'...
Meanwhile, OfflineLink prevents the original mutation from even sending the request, and a new mutation is generated and sent with the options you've given it.

How do you register a behavior to execute after the "Handle" method in NServiceBus 6?

I have an Endpoint with a Handle method. I would like to do something immediately before and immediately following Handle. I was able to get the step working before by imolementing LogCommandEntryBehavior : Behavior<IIncomingLogicalMessageContext>. What needs to be implemented to happen immediately following Handle?
In NServiceBus Version 6, the pipeline consists of a series of Stages, each one nested inside the previous like a set of Russian Dolls. For an incoming message, the stages are (in order):
ITransportReceiveContext,
IIncomingPhysicalMessageContext,
IIncomingLogicalMessageContext, and
IInvokeHandlerContext
When you create a behavior within a stage, you get passed a delegate called next(). When you call next() you execute the next behavior in the pipeline (which may move the pipeline to the next stage). The call to next() returns a Task which indicates when this inner part of the pipeline is done.
That gives you the opportunity to invoke your code before moving on to the next stage, and invoke more code after the next stage has been completed like this:
public class LogCommandEntryBehavior : Behavior<IIncomingLogicalMessageContext>
{
public override async Task Invoke(IIncomingLogicalMessageContext context, Func<Task> next)
{
// custom logic before calling the next step in the pipeline.
await next().ConfigureAwait(false);
// custom logic after all inner steps in the pipeline completed.
}
}
If you want to log information about the handling of a message, I recommend looking at the IInvokeHandlerContext stage. It contains information about how the message was handled and will be called once for every handler that is invoked (in cases where you have multiple). If you don't need info at that level then IIncomingLogicalMessageContext is probably all you need.
You can read more about the Version 6 pipeline in the Particular Docs site:
Steps, Stages and Connectors
Manipulate Pipeline with Behaviors

Is it possible to add additional logic to the Parse Server?

I want to perform some actions on X value depending on input from received in Y value. Can I perform such actions writing server side code in parse server?
Any pointers will be helpful.
Thanks.
Custom server side code can be achieved via cloud code. Cloud code allows you to create custom functions that are written in NodeJS and those functions can do various operations like: query from database, integrate with other solutions like: social, sending emails and more. The big advantage in parse-server is that you can use any npm module that you like from within the cloud code function and because there are millions of modules out there you have unlimited options.
Another very cool features of cloud code is the server side hooks
server side hooks allows you to write a code that will be triggered by parse-server core when an object is being saved or deleted. such events can be:
beforeSave - do something before the object is being saved to the database
afterSave - do something after the object is being saved
beforeDelete - do something before deleting
and more and more..
in order to define new cloud code function you will need to use the following code:
Parse.Cloud.define("{YOUR_FUNCTION_NAME}", function (request, response) {
// write your code, require some npm module and more...
});
In order to create server side hook you can write the following code:
Parse.Cloud.beforeSave("{PARSE_OBJECT_NAME}", function (request, response) {
// write your code and handle before saving an object
});
Triggering cloud code functions can be done easily via parse-server REST API or via parse-server client SDK's (iOS,Android,JavaScript and more)
There is a great guide on cloud code in here:
http://parseplatform.github.io/docs/cloudcode/guide/
Good Luck :)