小编fal*_*miw的帖子

Hasura: Allow users to not vote for their own post

I have three models User, Post, Vote

模式

I tried to create a role-based authorization where the author (the user who creates a post/blog) can't vote for their own post/blog. To identify users, I used Hasura session variables X-Hasura-User-Id. Configuring (Row insert) Permission Rules for Vote table by,

图片

Error:

{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_Vote_one.args.object",
        "code": "permission-error"
      },
      "message": "Check constraint violation. insert check constraint failed"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

But which given constraint violation for the …

graphql hasura

6
推荐指数
1
解决办法
169
查看次数

请求没有分布在他们的工作进程中

我只是在试验工作进程,因此试试这个:

const http = require("http");
const cluster = require("cluster");
const CPUs = require("os").cpus();
const numCPUs = CPUs.length;

if (cluster.isMaster) {
  console.log("This is the master process: ", process.pid);
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }
  cluster.on("exit", (worker) => {
    console.log(`worker process ${process.pid} has died`);
    console.log(`Only ${Object.keys(cluster.workers).length} remaining...`);
  });
} else {
  http
    .createServer((req, res) => {
      res.end(`process: ${process.pid}`);
      if (req.url === "/kill") {
        process.exit();
      }
      console.log(`serving from ${process.pid}`);
    })
    .listen(3000);
}
Run Code Online (Sandbox Code Playgroud)

我使用负载测试来检查“请求是否分布在他们的工作进程中?” 但我得到了同样的process.pid …

child-process node.js node-worker-threads

6
推荐指数
1
解决办法
139
查看次数