Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgraphile--makeExtendSchemaPlugin将查看器类型添加到模式--中继/Postgres_Postgresql_Graphql_Relay_Postgraphile - Fatal编程技术网

Postgresql Postgraphile--makeExtendSchemaPlugin将查看器类型添加到模式--中继/Postgres

Postgresql Postgraphile--makeExtendSchemaPlugin将查看器类型添加到模式--中继/Postgres,postgresql,graphql,relay,postgraphile,Postgresql,Graphql,Relay,Postgraphile,我是Relay、GraphQL和Postgres的新手,我正在尝试扩展PostGraphile创建的自动生成模式,以包括作为Relay主要功能的查看器类型 他们文档中的例子可能足以让大多数人使用,但我很难将其充实起来。我基本上希望它在字段viewer:viewer中添加一个适用于每种类型 任何帮助都会很棒 const { makeExtendSchemaPlugin, gql } = require('graphile-utils'); const AddViewerPlugin = make

我是Relay、GraphQL和Postgres的新手,我正在尝试扩展PostGraphile创建的自动生成模式,以包括作为Relay主要功能的查看器类型

他们文档中的例子可能足以让大多数人使用,但我很难将其充实起来。我基本上希望它在字段
viewer:viewer中添加一个适用于每种类型

任何帮助都会很棒

const { makeExtendSchemaPlugin, gql } = require('graphile-utils');

const AddViewerPlugin = makeExtendSchemaPlugin(build => {
  // Get any helpers we need from `build`
  const { pgSql: sql, inflection } = build;

  return {
    typeDefs: gql`...`,
    resolvers: {
      /*...*/ 
    },
  };
});

module.exports = AddViewerPlugin;
My db有一个public.person表和一个private.person\u account表,但我不太愿意重命名其中一个查看器。

您可以使用“postgraphile”对象进行自动模式检测。 并使用“makeExtendSchemaPlugin”向其添加额外的解析器

makeExtendSchemaPlugin创建一个插件对象,您可以在postgrahile对象构造时传递该对象

以下是postgraphile文档中的摘录:

const{postgraphile}=require(“postgraphile”);
const{makeExtendSchemaPlugin,gql}=require(“graphile utils”);const express=要求(“express”);
const{convertudstoaud}=require(“虚构的npm库”);
const MyForeignExchangePlugin=makeExtendSchemaPlugin(build=>{return{typeDefs:gql`extend-type-Product{pricinaucents:Int!@requires(列:[“price_in_us_cents”])},解析程序:{Product:{pricinaucents:async-Product=>{//注意,列被转换为字段,因此大小写从'price_in_us_cents'更改为'priceInUsCents`const{priceInUsCents}=product;return wait convertUsdToAud(priceInUsCents);},},},},};};
常量app=express();
应用程序使用(
postgraphile(process.env.DATABASE_URL,[“app_public”]{
graphiql:是的,
附录插件:[MyForeignExchangePlugin],})
);
app.listen(3030);