Skip to main content

Reference配置参考

These are all the configuration options available out of the box

以下列出 PostGraphile 开箱即用的全部配置选项。

import type {} from "postgraphile";
const preset: GraphileConfig.Preset = {
inflection: {
/* ... */
},
gather: {
/* ... */
},
schema: {
/* ... */
},
grafast: {
/* ... */
},
grafserv: {
/* ... */
},
};

export default preset;

preset.inflectionpreset.inflection(命名推导 inflection 配置)​

No options at this time

暂无配置项

preset.gatherpreset.gather(gather 阶段配置)​

{
installWatchFixtures?: boolean;
muteWarnings?: boolean;
pgIdentifiers?: "qualified" | "unqualified";
pgJwtTypes?: string | string[];
pgStrictFunctions?: boolean;

// Deprecated
pgFakeConstraintsAutofixForeignKeyUniqueness?: boolean;
pgJwtType?: string | [string, string];
}

gather.installWatchFixturesgather.installWatchFixtures(安装监听组件)​

Type: boolean | undefined

类型:boolean | undefined

Should we attempt to install the watch fixtures into the database?

是否在数据库中尝试安装 watch 监听组件(watch fixtures)。

Default: true

默认值:true

gather.muteWarningsgather.muteWarnings(屏蔽警告)​

Experimental实验性功能

Type: boolean | undefined

类型:boolean | undefined

Used in tests to mute expected warnings. Likely to be replaced when we add a diagnostics system.

用于在测试中屏蔽预期内的警告。待后续引入诊断系统后,该选项可能会被取代。

gather.pgIdentifiersgather.pgIdentifiers(PostgreSQL 标识符限定方式)​

Type: "qualified" | "unqualified" | undefined

类型:"qualified" | "unqualified" | undefined

With "qualified" (default) produces fully qualified identifiers, e.g. "public"."users".

设为 "qualified"(默认值)时,生成带 schema 的全限定标识符,例如 "public"."users"。

Set to "unqualified" to omit the schema name from table, function, and type identifiers (for example if you want select * from "users" rather than select * from "public"."users"); the runtime search_path then controls which schema is targeted. This is sometimes used for multitenant databases where each tenant has their own (identically structured) schema in the same databasee.

设为 "unqualified" 可在表、函数和类型的标识符中省略 schema 名称(例如生成 select * from "users" 而非 select * from "public"."users"),此时运行时的 search_path 将决定目标 schema。这种用法常见于多租户数据库——每个租户在同一数据库中拥有各自独立但结构相同的 schema。

gather.pgJwtTypesgather.pgJwtTypes(PostgreSQL JWT 类型列表)​

Type: string | string[] | undefined

类型:string | string[] | undefined

If you would like PostGraphile to automatically recognize certain PostgreSQL types as a JWT, you should pass a list of their identifiers here: pgJwtTypes: ['my_schema.my_jwt_type', 'my_schema."myOtherJwtType"']

如果希望 PostGraphile 将特定的 PostgreSQL 类型自动识别为 JWT,可在此传入对应的类型标识符列表: pgJwtTypes: ['my_schema.my_jwt_type', 'my_schema."myOtherJwtType"']

Parsing is similar to PostgreSQL's parsing, so identifiers are lower-cased unless they are escaped via double quotes.

其解析规则与 PostgreSQL 一致:除非使用双引号转义,否则标识符会自动转为小写。

You can alternatively supply a comma-separated list if you prefer: pgJwtTypes: 'my_schema.my_jwt_type,my_schema."myOtherJwtType"'

也可以改为传入逗号分隔的字符串列表: pgJwtTypes: 'my_schema.my_jwt_type,my_schema."myOtherJwtType"'

gather.pgStrictFunctionsgather.pgStrictFunctions(严格函数参数)​

Type: boolean | undefined

类型:boolean | undefined

If true, we'll treat all arguments that don't have defaults as being required.

若设为 true,所有未设置默认值的函数参数都将被视为必填参数。

Deprecated已弃用配置​

These settings should no longer be used.

以下配置项已弃用,不应继续使用。

gather.pgFakeConstraintsAutofixForeignKeyUniquenessgather.pgFakeConstraintsAutofixForeignKeyUniqueness(自动修复假约束外键唯一性)​

Deprecated已弃用

We strongly recommend that you fix the uniqueness yourself.

强烈建议由你自行修正外键对应的唯一性约束。

Type: boolean | undefined

类型:boolean | undefined

gather.pgJwtTypegather.pgJwtType(PostgreSQL JWT 类型)​

Deprecated已弃用

use pgJwtTypes instead

请改用 pgJwtTypes

Type: string | [string, string] | undefined

类型:string | [string, string] | undefined

preset.schemapreset.schema(schema 阶段配置)​

{
defaultBehavior?: string;
defaultNodeIdCodec?: string;
dontSwallowErrors?: boolean;
exportSchemaIntrospectionResultPath?: string;
exportSchemaSDLPath?: string;
jsonScalarAsString?: boolean;
muteWarnings?: boolean;
nodeIdFieldName?: string;
pgDefaultPartitionedTableExpose?: "both" | "child" | "parent";
pgForbidSetofFunctionsToReturnNull?: boolean;
pgFunctionsPreferNodeId?: boolean;
pgJwtSecret?: Secret;
pgJwtSignOptions?: SignOptions;
pgMutationPayloadRelations?: boolean;
pgOrderByNullsLast?: boolean;
pgUseCustomNetworkScalars?: boolean;
pgV4UseTableNameForNodeIdentifier?: boolean;
retryOnInitFail?: boolean | ((error: Error, attempts: number, delay: number) => boolean | Promise<boolean>);
sortExport?: boolean;
}

schema.defaultBehaviorschema.defaultBehavior(默认 behavior 规则)​

Type: string | undefined

类型:string | undefined

A behavior string to prepend to all behavior checks, can be overriden but is a great way to disable things by default and then re-enable them in specific locations.

附加在所有 behavior 检查最前端的规则字符串;它可被后续规则覆盖,非常适合先默认禁用某些功能,再在特定位置按需重新启用。

schema.defaultNodeIdCodecschema.defaultNodeIdCodec(默认 Node ID codec)​

Type: string | undefined
Default value: "base64JSON"

类型:string | undefined
默认值:"base64JSON"

The default Node ID codec to use. May be overridden on a table-by-table basis using the @nodeIdCodec smart tag.

默认使用的 Node ID codec。可使用 @nodeIdCodec smart tag 按表逐一覆盖。

Use build.registerNodeIdCodec to register your own codecs.

可通过 build.registerNodeIdCodec 注册自定义 codec。

schema.dontSwallowErrorsschema.dontSwallowErrors(禁止吞掉错误)​

Type: boolean | undefined

类型:boolean | undefined

SwallowErrorsPlugin by default will "swallow" errors, allowing you to continue building your GraphQL schema even if errors (such as naming conflicts) occur. It is recommended that you set this option to true in your production configuration to disable this behavior.

默认情况下,SwallowErrorsPlugin 会“吞掉”错误,使 GraphQL schema 在遇到错误(如命名冲突)时仍能继续构建。建议在生产环境配置中将该选项设为 true,以禁用此行为。

schema.exportSchemaIntrospectionResultPathschema.exportSchemaIntrospectionResultPath(导出 schema introspection 结果路径)​

Type: string | undefined

类型:string | undefined

schema.exportSchemaSDLPathschema.exportSchemaSDLPath(导出 schema SDL 路径)​

Type: string | undefined

类型:string | undefined

schema.jsonScalarAsStringschema.jsonScalarAsString(JSON 标量转为字符串)​

Type: boolean | undefined

类型:boolean | undefined

Set 'true' if you want JSON values to be stringified.

若希望将 JSON 值序列化为字符串,请设为 'true'。

schema.muteWarningsschema.muteWarnings(屏蔽警告)​

Experimental实验性功能

Type: boolean | undefined

类型:boolean | undefined

Used in tests to mute expected warnings. Likely to be replaced when we add a diagnostics system.

用于在测试中屏蔽预期内的警告。待后续引入诊断系统后,该选项可能会被取代。

schema.nodeIdFieldNameschema.nodeIdFieldName(Node ID 字段名)​

Type: string | undefined

类型:string | undefined

If your schema includes compatibility with the GraphQL Global Object Identification Specification, typically this will be called 'id'. However the term 'id' often conflicts with databases which commonly use 'id' as their primary key name, so we give you the option to rename it.

如果 GraphQL schema 需要兼容 GraphQL 全局对象标识规范(Global Object Identification Specification),该字段通常命名为 'id'。但数据库中也普遍将主键命名为 'id',极易产生冲突,因此这里提供了重命名该字段的选项。

schema.pgDefaultPartitionedTableExposeschema.pgDefaultPartitionedTableExpose(分区表默认暴露方式)​

Type: "both" | "child" | "parent" | undefined

类型:"both" | "child" | "parent" | undefined

What to expose when we see a partitioned table (or its child partitions).

控制遇到分区表及其子分区时应暴露哪些表。

  • parent - only expose the parent (partitioned) table, not the children (partitions)

    parent - 仅暴露父表(分区主表),不暴露子表(各分区)

  • child - only expose the children (partitions), not the parent partitioned table

    child - 仅暴露子表(各分区),不暴露父表(分区主表)

  • both - expose both the parent (partitioned) table and all of its partitions

    both - 同时暴露父表(分区主表)及其所有子分区

schema.pgForbidSetofFunctionsToReturnNullschema.pgForbidSetofFunctionsToReturnNull(禁止 setof 函数返回 null)​

Type: boolean | undefined

类型:boolean | undefined

If true, setof functions cannot return null, so our list and connection types can use GraphQLNonNull in more places.

若设为 true,setof 函数将不允许返回 null,从而使列表与 Connection 类型能在更多位置使用 GraphQLNonNull(非空约束)。

schema.pgFunctionsPreferNodeIdschema.pgFunctionsPreferNodeId(函数优先使用 Node ID)​

Type: boolean | undefined

类型:boolean | undefined

schema.pgJwtSecretschema.pgJwtSecret(PostgreSQL JWT 签名密钥)​

Type: Secret | undefined

类型:Secret | undefined

schema.pgJwtSignOptionsschema.pgJwtSignOptions(PostgreSQL JWT 签名选项)​

Type: SignOptions | undefined

类型:SignOptions | undefined

schema.pgMutationPayloadRelationsschema.pgMutationPayloadRelations(Mutation payload 关联字段)​

Type: boolean | undefined

类型:boolean | undefined

schema.pgOrderByNullsLastschema.pgOrderByNullsLast(排序时 NULL 置后)​

Type: boolean | undefined

类型:boolean | undefined

schema.pgUseCustomNetworkScalarsschema.pgUseCustomNetworkScalars(启用自定义网络标量类型)​

Type: boolean | undefined

类型:boolean | undefined

schema.pgV4UseTableNameForNodeIdentifierschema.pgV4UseTableNameForNodeIdentifier(沿用 v4 以表名作为 Node 标识符)​

Type: boolean | undefined

类型:boolean | undefined

schema.retryOnInitFailschema.retryOnInitFail(初始化失败时重试)​

Type: boolean | ((error: Error, attempts: number, delay: number) => boolean | Promise<boolean>) | undefined

类型:boolean | ((error: Error, attempts: number, delay: number) => boolean | Promise<boolean>) | undefined

When false (default), Grafserv will exit if it fails to build the initial schema (for example if it cannot connect to the database, or if there are fatal naming conflicts in the schema). When true, PostGraphile will keep trying to rebuild the schema indefinitely, using an exponential backoff between attempts, starting at 100ms and increasing up to 30s delay between retries. When a function, the function will be called passing the error and the number of attempts, and it should return true to retry, false to permanently abort trying.

设为 false(默认值)时,若初始 schema 构建失败(例如无法连接数据库,或 schema 中存在致命的命名冲突),Grafserv 会直接退出。设为 true 时,PostGraphile 将无限次重试重建 schema,重试间隔采用指数退避策略,从 100ms 起步,最高增至 30s。若传入函数,每次重试前都会调用该函数并传入错误对象与已尝试次数;返回 true 表示继续重试,返回 false 则彻底放弃。

schema.sortExportschema.sortExport(导出时进行排序)​

Type: boolean | undefined

类型:boolean | undefined

preset.grafastpreset.grafast(Grafast 配置)​

{
context?: Partial<Grafast.Context> | ((ctx: Partial<Grafast.RequestContext>, args: Grafast.ExecutionArgs) => PromiseOrValue<Partial<Grafast.Context>>);
explain?: boolean | string[];
maxPlanningDepth?: number;
timeouts?: GrafastTimeouts;

// Advanced
distributorPauseDuration?: number;
distributorTargetBufferSize?: number;
distributorTargetBufferSizeIncrement?: number;
}

grafast.contextgrafast.context(GraphQL context 上下文)​

Type: Partial<Grafast.Context> | ((ctx: Partial<Grafast.RequestContext>, args: Grafast.ExecutionArgs) => PromiseOrValue<Partial<Grafast.Context>>) | undefined

类型:Partial<Grafast.Context> | ((ctx: Partial<Grafast.RequestContext>, args: Grafast.ExecutionArgs) => PromiseOrValue<Partial<Grafast.Context>>) | undefined

An object to merge into the GraphQL context. Alternatively, pass an (optionally asynchronous) function that returns an object to merge into the GraphQL context.

要合并到 GraphQL 上下文(context)中的对象。也可以传入一个同步或异步函数,以其返回的对象合并进 GraphQL 上下文。

grafast.explaingrafast.explain(执行计划 explain 输出)​

Type: boolean | string[] | undefined

类型:boolean | string[] | undefined

A list of 'explain' types that should be included in extensions.explain.

指定要包含在 extensions.explain 中的 'explain' 信息类型列表。

  • plan will cause the plan JSON to be included

    plan 会将执行计划 JSON 包含在结果中

  • other values are dependent on the plugins in play

    其他可选值取决于当前启用的插件

If set to true then all possible explain types will be exposed.

若设为 true,则会暴露所有可用的 explain 类型。

grafast.maxPlanningDepthgrafast.maxPlanningDepth(最大规划深度)​

Type: number | undefined

类型:number | undefined

How many planning layers deep do we allow? Should be handled by validation.

允许的最大规划层级深度。通常应配合查询校验(validation)共同控制。

A planning layer can happen due to:

以下情况均可能产生新的规划层级:

  • A nested selection set

    嵌套的选择集(selection set)

  • Planning a field return type

    规划字段的返回类型

  • A list position

    列表位置

  • A polymorphic type

    多态类型

  • A deferred/streamed response

    延迟(defer)或流式(stream)响应

These reasons may each cause 1, 2 or 3 planning layers to be added, so this limit should be set quite high - e.g. 6x the selection set depth.

上述每种情况都可能增加 1 到 3 层规划深度,因此该上限应当设置得足够高——例如设为选择集最大深度的 6 倍。

grafast.timeoutsgrafast.timeouts(超时配置)​

Type: GrafastTimeouts | undefined

类型:GrafastTimeouts | undefined

Advanced高级配置​

Only use these settings if you know what you are doing!

仅在明确了解其作用与影响时才应调整这些选项!

grafast.distributorPauseDurationgrafast.distributorPauseDuration(分发器暂停时长)​

Advanced高级

Type: number | undefined

类型:number | undefined

Duration (in milliseconds) for the distributor to pause whilst waiting for the slowest consumer to advance once the distributorTargetBufferSize has been reached.

当达到 distributorTargetBufferSize 上限时,分发器暂停并等待最慢消费者跟进的时长(单位:毫秒)。

Must be at least 0.

必须大于或等于 0。

grafast.distributorTargetBufferSizegrafast.distributorTargetBufferSize(分发器目标缓冲区大小)​

Advanced高级

Type: number | undefined

类型:number | undefined

This supports the $step.cloneStreams = true option, allowing multiple consumers to consume the same underlying stream, but tries to avoid any one consumer getting more than distributorTargetBufferSize items ahead of any other. When a fast consumer gets this far ahead of the slowest consumer, it will be paused for distributorPauseDuration milliseconds to allow the slowest consumer to advance. Should the slowest consumer not advance in time, the fast consumer will be allowed to continue and all intermediary results will be cached - so beware of memory exhaustion and be sure to place sensible limits on your queries (and construct them wisely).

该选项配合 $step.cloneStreams = true 使用,允许多个消费者共同读取同一个底层流,同时尽量避免某个消费者领先其他消费者超过 distributorTargetBufferSize 条数据。当较快的消费者领先最慢消费者达到该阈值时,系统会将其暂停 distributorPauseDuration 毫秒,以便最慢消费者赶上。若超时后最慢消费者仍未推进,较快消费者将继续执行,所有中间结果则会被缓存——因此请务必警惕内存耗尽风险,为查询设置合理限制(并谨慎编写查询)。

This must be set higher than the largest @stream(initialCount:) argument you want to support.

该值必须大于你需要支持的最大 @stream(initialCount:) 参数值。

grafast.distributorTargetBufferSizeIncrementgrafast.distributorTargetBufferSizeIncrement(分发器目标缓冲区增量)​

Advanced高级

Type: number | undefined

类型:number | undefined

When the distributorTargetBufferSize is exceeded, every time we get distributorTargetBufferSizeIncrement items further ahead, we'll pause again.

在超出 distributorTargetBufferSize 后,每当快慢消费者的差距继续扩大 distributorTargetBufferSizeIncrement 条数据时,系统便会再次暂停等待。

Must be at least 1. Recommend you set this fairly large.

必须大于或等于 1,建议将其设为较大的数值。

preset.grafservpreset.grafserv(Grafserv 服务配置)​

{
allowedRequestContentTypes?: readonly RequestContentType[];
dangerouslyAllowAllCORSRequests?: boolean;
eventStreamPath?: string;
graphiql?: boolean;
graphiqlOnGraphQLGET?: boolean;
graphiqlPath?: string;
graphiqlStaticPath?: string;
graphqlOverGET?: boolean;
graphqlPath?: string;
host?: string;
maskError?: MaskErrorFn;
maxRequestLength?: number;
outputDataAsString?: boolean;
parseAndValidateCacheSize?: number;
pgJwtSecret?: Secret | GetPublicKeyOrSecret;
pgJwtVerifyOptions?: VerifyOptions;
port?: number;
schemaWaitTime?: number;
watch?: boolean;
websocketKeepalive?: number;
websockets?: boolean;
}

grafserv.allowedRequestContentTypesgrafserv.allowedRequestContentTypes(允许的请求 Content-Type)​

Type: readonly RequestContentType[] | undefined

类型:readonly RequestContentType[] | undefined

By default application/json and application/graphql are supported (DEFAULT_ALLOWED_REQUEST_CONTENT_TYPES). You may add application/x-www-form-urlencoded to the list, but be aware that doing so potentially opens you to CSRF issues even if you're not using CORS since this media type is handled specially by browsers - ensure that you have CSRF protections in place.

默认支持 application/json 和 application/graphql(即 DEFAULT_ALLOWED_REQUEST_CONTENT_TYPES)。你也可以将 application/x-www-form-urlencoded 加入列表,但要注意浏览器会对该媒体类型做特殊处理,即使未开启 CORS 也可能带来 CSRF 安全隐患——开启前请务必做好 CSRF 防护。

Note further that if you're using CORS the other media types are not safe, and you should still use CSRF protection.

此外请注意,如果启用了 CORS,其他媒体类型同样存在安全风险,仍应配套使用 CSRF 防护措施。

grafserv.dangerouslyAllowAllCORSRequestsgrafserv.dangerouslyAllowAllCORSRequests(允许全部 CORS 请求,危险)​

Type: boolean | undefined

类型:boolean | undefined

Temporary hack to allow easy testing with graphql-http.com

为便于使用 graphql-http.com 进行测试而提供的临时方案。

grafserv.eventStreamPathgrafserv.eventStreamPath(事件流路径)​

Type: string | undefined

类型:string | undefined

The path at which the GraphQL event stream would be made available; usually /graphql/stream

GraphQL 事件流(Event Stream)的挂载路径;通常为 /graphql/stream。

grafserv.graphiqlgrafserv.graphiql(启用 GraphiQL)​

Type: boolean | undefined

类型:boolean | undefined

grafserv.graphiqlOnGraphQLGETgrafserv.graphiqlOnGraphQLGET(在 GraphQL GET 请求时渲染 GraphiQL)​

Type: boolean | undefined

类型:boolean | undefined

If true, then we will render GraphiQL on GET requests to the /graphql endpoint

若设为 true,向 /graphql 端点发起 GET 请求时将渲染 GraphiQL 界面。

grafserv.graphiqlPathgrafserv.graphiqlPath(GraphiQL 路径)​

Type: string | undefined

类型:string | undefined

The path at which GraphiQL will be available; usually /

GraphiQL 页面的访问路径;通常为 /。

grafserv.graphiqlStaticPathgrafserv.graphiqlStaticPath(GraphiQL 静态资源路径)​

Type: string | undefined

类型:string | undefined

The path from which GraphiQL's static assets are served, must end in a slash. Usually /ruru-static/

用于提供 GraphiQL 静态资源的路径,必须以斜杠结尾;通常为 /ruru-static/。

grafserv.graphqlOverGETgrafserv.graphqlOverGET(允许通过 GET 执行 GraphQL)​

Type: boolean | undefined

类型:boolean | undefined

If true, allow GraphQL over GET requests. This has security ramifications, exercise caution.

若设为 true,则允许通过 HTTP GET 请求执行 GraphQL 查询。该选项存在安全隐患,请谨慎使用。

grafserv.graphqlPathgrafserv.graphqlPath(GraphQL 端点路径)​

Type: string | undefined

类型:string | undefined

The path at which GraphQL will be available; usually /graphql

GraphQL 服务接口的挂载路径;通常为 /graphql。

grafserv.hostgrafserv.host(监听主机地址)​

Type: string | undefined

类型:string | undefined

Host to listen on

服务监听的主机地址。

grafserv.maskErrorgrafserv.maskError(错误脱敏函数)​

Type: MaskErrorFn | undefined

类型:MaskErrorFn | undefined

If you would like to customize the way in which errors are masked, you may pass your own error masking function here. You can also import defaultMaskError from grafserv.

如需自定义错误信息的脱敏处理方式,可在此传入自定义函数。你也可以从 grafserv 导入 defaultMaskError 作为基础实现。

grafserv.maxRequestLengthgrafserv.maxRequestLength(最大请求体长度)​

Type: number | undefined

类型:number | undefined

The length, in bytes, for the largest request body that grafserv will accept

Grafserv 允许接收的最大请求体长度(单位:字节)。

grafserv.outputDataAsStringgrafserv.outputDataAsString(以字符串形式输出响应数据)​

Type: boolean | undefined

类型:boolean | undefined

Use grafast 'string' optimization - response will be partially stringified already, use stringifyPayload before sending to the user

启用 Grafast 的 'string' 优化——响应数据已提前部分字符串化,发送给客户端前请先调用 stringifyPayload 处理。

grafserv.parseAndValidateCacheSizegrafserv.parseAndValidateCacheSize(解析与校验缓存大小)​

Type: number | undefined
Default value: 500

类型:number | undefined
默认值:500

How many documents should we cache the parse and validate result for?

缓存多少份 GraphQL 文档的解析(parse)与校验(validate)结果。

grafserv.pgJwtSecretgrafserv.pgJwtSecret(PostgreSQL JWT 验证密钥)​

Type: Secret | GetPublicKeyOrSecret | undefined

类型:Secret | GetPublicKeyOrSecret | undefined

grafserv.pgJwtVerifyOptionsgrafserv.pgJwtVerifyOptions(PostgreSQL JWT 校验选项)​

Type: VerifyOptions | undefined

类型:VerifyOptions | undefined

grafserv.portgrafserv.port(监听端口号)​

Type: number | undefined

类型:number | undefined

Port number to listen on

服务监听的端口号。

grafserv.schemaWaitTimegrafserv.schemaWaitTime(等待 schema 就绪超时时间)​

Type: number | undefined

类型:number | undefined

How long (in milliseconds) should we wait for a schema promise to resolve before sending a failure to the client?

在向客户端返回失败响应之前,等待 schema Promise 解析的最长时长(单位:毫秒)。

grafserv.watchgrafserv.watch(启用监听模式)​

Type: boolean | undefined

类型:boolean | undefined

Set true to enable watch mode

设为 true 以启用监听模式(watch mode)。

grafserv.websocketKeepalivegrafserv.websocketKeepalive(WebSocket 心跳保活间隔)​

Type: number | undefined
Default value: 12_000

类型:number | undefined
默认值:12_000

Duration (in milliseconds) between pings. Set to -1 to disable.

两次心跳 ping 之间的时间间隔(单位:毫秒)。设为 -1 可禁用。

grafserv.websocketsgrafserv.websockets(启用 WebSocket 传输)​

Type: boolean | undefined

类型:boolean | undefined

Should we enable a websockets transport if available?

若条件允许,是否启用 WebSocket 传输通道。

preset.rurupreset.ruru(Ruru 配置)​

Exercise caution请谨慎修改

In general you shouldn't change the Ruru settings; PostGraphile handles them for you.

通常无需手动修改 Ruru 配置,PostGraphile 会自动为你接管处理。

{
clientConfig?: RuruClientConfig;
enableProxy?: boolean;
endpoint?: string;
htmlParts?: {
metaTags?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined;
titleTag?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined;
... 5 more ...;
bodyInitScript?: string | ... 1 more ... | undefined;
};
port?: number;
staticPath?: string;
subscriptionEndpoint?: string;
subscriptions?: boolean;
}

ruru.clientConfigruru.clientConfig(Ruru 客户端配置)​

Type: RuruClientConfig | undefined

类型:RuruClientConfig | undefined

Will be serialized and sent to the client

该配置会被序列化并发送给客户端。

ruru.enableProxyruru.enableProxy(启用代理)​

Type: boolean | undefined

类型:boolean | undefined

ruru.endpointruru.endpoint(GraphQL 端点 URL)​

Type: string | undefined

类型:string | undefined

The URL to the GraphQL endpoint. (http:// or https://)

GraphQL 端点的完整 URL(以 http:// 或 https:// 开头)。

ruru.htmlPartsruru.htmlParts(自定义 HTML 片段)​

Type: { metaTags?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined; titleTag?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined; ... 5 more ...; bodyInitScript?: string | ... 1 more ... | undefined; } | undefined

类型:{ metaTags?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined; titleTag?: string | ((original: string, clientConfig: BakedRuruClientConfig, serverConfig: RuruConfig, htmlParts: RuruHTMLParts, key: keyof RuruHTMLParts) => string) | undefined; ... 5 more ...; bodyInitScript?: string | ... 1 more ... | undefined; } | undefined

Override the HTML parts that are used to build the Ruru

覆盖用于构建 Ruru 页面的 HTML 片段。

ruru.portruru.port(Ruru 监听端口)​

Type: number | undefined

类型:number | undefined

The port for ruru CLI to listen on.

ruru CLI 监听的端口号。

ruru.staticPathruru.staticPath(Ruru 静态资源路径)​

Type: string | undefined

类型:string | undefined

Ruru's static assets must be served for Ruru to work. Pass the URL to the root of this folder; it must end in a slash. Defaults to https://unpkg.com/ruru@${version}/static/ in most places, though the CLI defaults to /ruru-static/ since it serves its own files.

Ruru 需要托管其静态资源才能正常运行。请传入指向该资源目录根目录的 URL,且必须以斜杠结尾。大多数环境下默认值为 https://unpkg.com/ruru@${version}/static/,而 CLI 会自行托管这些文件,因此默认为 /ruru-static/。

ruru.subscriptionEndpointruru.subscriptionEndpoint(GraphQL Subscription 端点 URL)​

Type: string | undefined

类型:string | undefined

The URL to the GraphQL subscriptions endpoint. (ws:// or wss://)

GraphQL Subscription 端点的 URL(以 ws:// 或 wss:// 开头)。

ruru.subscriptionsruru.subscriptions(启用 Subscription)​

Type: boolean | undefined

类型:boolean | undefined