How to get all pipes from api pipefy? - taskmanager

I find api, but I don't understand. How to get list pipes. Without ids.

You can use the organizations object and get all the pipes of the organization.
Example:
{
organization(id: 123) {
pipes {
id
}
}
}

Related

Best practice of Read-Modify-Write Rest Api Design

I have a restful api to update the bunch of objects on the server side. For example, I have an object like this:
{
counter: int,
bit_mask: int,
other_value: string,
}
on the client side, I want to do some update based on the inner method on the server side, like:
{
counter++,
bit_mask.some_inner_method(some_value),
other_value = new_value
}
I want to expose an idempotent and atomic rest API for this kind of update instead of read it to the client-side and writing it back to the server side. Here is my naive thought on the body of this API
{
overwrite: {
other_value: "new_value",
},
updates: [
{
property: "counter",
operator: "inc"
},
{
property: "bit_mask",
operator: "some_inner_method",
params: ["some_value"]
}
]
}
I think this should be a common use case, but I didn't find any discussion about it online. Is there any better solution to this scenario?
There is something like an security-bot design. In this design a non-service-deamon who not accept any incoming connections and have no db but read/write to/from Microservices using a Regelwerk. Like an arbiter.

Nestjs: AuthGuard validation per request?

I have a nestjs graphql backend and I’d like to do the token authentication once per http request.
The Problem:
For one http request my global defined guard app.useGlobalGuards(new GqlAuthGuard()) is validating the user 7 times if I have the following graphql query:
{
article(id:1)
{
id
name
}
categories {
id
name
}
topics {
id
name
}
lawmakers {
id
name
}
articleTypes {
id
name
}
articleStatuses {
id
name
}
countries {
id
name
}
}
It looks that the AuthGuard is called for each Module that is affected by the query.
How can I get rid of this multiple validation?
You could probably end up attaching some sort of validated or authenticated property to the request context so that on each new guard the request goes through it could be shorted with that field. The problem is that with your query, you are essentially making 7 http calls in one, and Nest will run the guard against each query and mutation being requested because that's how a global guard is bound. The only real way around it is just to add some sort of short circuit that makes the complex logic not happen.

How to fetch GitHub branch names using GraphQL

Using GitHub GraphQL API (v.4) I would like to get all the branch names existing on a given repository.
My attempt
{
repository(name: "my-repository", owner: "my-account") {
... on Ref {
name
}
}
}
returns error:
{'data': None, 'errors': [{'message': "Fragment on Ref can't be spread inside Repository", 'locations': [{'line': 4, 'column': 13}]}]}
Here's how to retrieve 10 branches from a repo:
{
repository(name: "git-point", owner: "gitpoint") {
refs(first: 10, , refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
PS: You usually use spread when dealing with an Union type (like IssueTimeline for example, which is composed of different kind of objects, so you can spread on a particular object type to query specific fields.
You might need to use pagination to get all branches

Generating multiple responses from AWS API Gateway

I've been fiddling around with API Gateway with DynamoDB. The below map template allows me to generate a single JSON response from AWS API Gateway.
{
"TableName": "NPddb"
"PrimaryKey": "id",
"KeyConditionExpression": "id = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "$input.params('id')"
}
}
}
which will result in a nice JSON being published at a specified "id".
This is all well and nice, but how do I return say two items or even the entire table? Does this come under a lambda call?
The solution was the create a Global Secondary Index in the DynamoDB table and query that. In this case, I'm querying GSI "atype-index" for the string "atype".
{
"TableName": "NPddb",
"IndexName": "atype-index",
"KeyConditionExpression": "atype = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "$input.params('atype')"
}
}
}

JSON API design - express

I want to write a JSON API.
My problem is, that sometimes I want to query for an ID, sometimes for a String.
One option would be to add a querystring, for example:
example.com/user/RandomName
example.com/user/1234556778898?id=true
and use it like:
api.get('user/:input', function(req, res) {
if(req.query.id) {
User.find({ '_id': req.params.input }, cb);
} else {
User.find({ 'name': req.params.input }, cb);
}
};
But this seems like bad practice to me, since it leads to a bunch of conditional expressions.
Are there more elegant ways?
I would suggest handling two endpoints. One for getting ALL the users and one for getting a SPECIFC user by ID.
example.com/users
example.com/users/:id
The second endpoint can be used to find a specific user by id.
The first endpoint can be used to find all users, but filters can be applied to this endpoint.
For example: example.com/users?name=RandomName
By doing this, you can very easily create a query in your Node service based on the parameters that are in the URL.
api.get('/users', function(req, res) {
// generate the query object based on URL parameters
var queryObject = {};
for (var key in req.query) {
queryObject[key] = req.query[key];
}
// find the users with the filter applied.
User.find(queryObject, cb);
};
By constructing your endpoints this way, you are following a RESTful API standard which will make it very easy for others to understand your code and your API. In addition, you are constructing an adaptable API as you can now filter your users by any field by adding the field as a parameter to the URL.
See this response for more information on when to use path parameters vs URL parameters.