graphile-build-pg
Advanced tools
Comparing version 5.0.0-alpha.17 to 5.0.0-alpha.18
@@ -1,2 +0,1 @@ | ||
export { PgCodecAttributeTags, PgCodecRelationTags, PgCodecTags, PgResourceTags, PgSmartTagsDict, } from "./interfaces.js"; | ||
export { getWithPgClientFromPgService, withPgClientFromPgService, } from "./pgServices.js"; | ||
@@ -3,0 +2,0 @@ export { PgAllRowsPlugin } from "./plugins/PgAllRowsPlugin.js"; |
import type { PgRegistry, WithPgClient } from "@dataplan/pg"; | ||
import type { PromiseOrDirect } from "grafast"; | ||
export interface PgResourceTags extends PgSmartTagsDict { | ||
name: string; | ||
/** For a computed attribute function/etc, what field name should we use? */ | ||
fieldName: string; | ||
/** For a custom mutation function, what field name should we use on the payload to store the result? */ | ||
resultFieldName: string; | ||
behavior: string | string[]; | ||
primaryKey: string; | ||
foreignKey: string | string[]; | ||
unique: string | string[]; | ||
deprecated: string | string[]; | ||
declare global { | ||
namespace GraphileBuild { | ||
interface PgResourceTags extends PgSmartTagsDict { | ||
name: string; | ||
/** For a computed attribute function/etc, what field name should we use? */ | ||
fieldName: string; | ||
/** For a custom mutation function, what field name should we use on the payload to store the result? */ | ||
resultFieldName: string; | ||
behavior: string | string[]; | ||
primaryKey: string; | ||
foreignKey: string | string[]; | ||
unique: string | string[]; | ||
deprecated: string | string[]; | ||
} | ||
interface PgResourceUniqueTags extends PgSmartTagsDict { | ||
/** The field name for the root-level accessor for a row by this unique constraint */ | ||
fieldName: string; | ||
behavior: string | string[]; | ||
} | ||
interface PgCodecRelationTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
notNull: true; | ||
} | ||
interface PgCodecRefTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
notNull: true; | ||
} | ||
interface PgCodecAttributeTags extends PgSmartTagsDict { | ||
name: string; | ||
behavior: string | string[]; | ||
notNull: true; | ||
} | ||
interface PgCodecTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
implements: string | string[]; | ||
interface: string; | ||
name: string; | ||
unionMember: string | string[]; | ||
} | ||
interface PgSmartTagsDict { | ||
[tagName: string]: null | true | string | (string | true)[]; | ||
} | ||
} | ||
} | ||
export interface PgResourceUniqueTags extends PgSmartTagsDict { | ||
/** The field name for the root-level accessor for a row by this unique constraint */ | ||
fieldName: string; | ||
behavior: string | string[]; | ||
} | ||
export interface PgCodecRelationTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
notNull: true; | ||
} | ||
export interface PgCodecRefTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
notNull: true; | ||
} | ||
export interface PgCodecAttributeTags extends PgSmartTagsDict { | ||
name: string; | ||
behavior: string | string[]; | ||
notNull: true; | ||
} | ||
export interface PgCodecTags extends PgSmartTagsDict { | ||
behavior: string | string[]; | ||
deprecated: string | string[]; | ||
implements: string | string[]; | ||
interface: string; | ||
name: string; | ||
unionMember: string | string[]; | ||
} | ||
export interface PgSmartTagsDict { | ||
[tagName: string]: null | true | string | (string | true)[]; | ||
} | ||
export interface PgAdaptor<TAdaptor extends keyof GraphileConfig.PgDatabaseAdaptorOptions = keyof GraphileConfig.PgDatabaseAdaptorOptions> { | ||
@@ -52,3 +56,3 @@ createWithPgClient: (adaptorSettings: GraphileConfig.PgServiceConfiguration<TAdaptor>["adaptorSettings"], variant?: "SUPERUSER" | null) => PromiseOrDirect<WithPgClient>; | ||
interface PgResourceExtensions { | ||
tags: Partial<PgResourceTags>; | ||
tags: Partial<GraphileBuild.PgResourceTags>; | ||
singleOutputParameterName?: string; | ||
@@ -63,12 +67,12 @@ /** For v4 compatibility, what's the name of the actual table. */ | ||
interface PgResourceUniqueExtensions { | ||
tags: Partial<PgResourceUniqueTags>; | ||
tags: Partial<GraphileBuild.PgResourceUniqueTags>; | ||
} | ||
interface PgCodecRelationExtensions { | ||
tags: Partial<PgCodecRelationTags>; | ||
tags: Partial<GraphileBuild.PgCodecRelationTags>; | ||
} | ||
interface PgCodecRefExtensions { | ||
tags: Partial<PgCodecRefTags>; | ||
tags: Partial<GraphileBuild.PgCodecRefTags>; | ||
} | ||
interface PgCodecAttributeExtensions { | ||
tags: Partial<PgCodecAttributeTags>; | ||
tags: Partial<GraphileBuild.PgCodecAttributeTags>; | ||
} | ||
@@ -78,3 +82,3 @@ interface PgCodecExtensions { | ||
isTableLike?: boolean; | ||
tags: Partial<PgCodecTags>; | ||
tags: Partial<GraphileBuild.PgCodecTags>; | ||
} | ||
@@ -84,3 +88,3 @@ } | ||
interface BuildInput { | ||
pgRegistry: PgRegistry<any, any, any>; | ||
pgRegistry: PgRegistry; | ||
} | ||
@@ -87,0 +91,0 @@ } |
import "./PgTablesPlugin.js"; | ||
import "../interfaces.js"; | ||
import "graphile-config"; | ||
import type { PgCodecAttribute, PgCodecWithAttributes } from "@dataplan/pg"; | ||
import type { PgCodec, PgCodecAttribute, PgCodecWithAttributes } from "@dataplan/pg"; | ||
import type { GraphQLOutputType } from "grafast/graphql"; | ||
declare global { | ||
namespace GraphileBuild { | ||
interface Build { | ||
pgResolveOutputType(codec: PgCodec, notNull?: boolean): [baseCodec: PgCodec, resolvedType: GraphQLOutputType] | null; | ||
} | ||
interface Inflection { | ||
@@ -8,0 +12,0 @@ /** |
@@ -29,3 +29,3 @@ "use strict"; | ||
}); | ||
const resolveResult = resolveOutputType(build, attribute.codec, attribute.notNull); | ||
const resolveResult = build.pgResolveOutputType(attribute.codec, attribute.notNull || attribute.extensions?.tags?.notNull); | ||
if (!resolveResult) { | ||
@@ -37,7 +37,2 @@ console.warn(`Couldn't find a 'output' variant for PgCodec ${pgCodec.name}'s '${attributeName}' attribute (${attribute.codec.name}; array=${!!attribute.codec.arrayOfCodec}, domain=${!!attribute.codec | ||
const [baseCodec, type] = resolveResult; | ||
if (!type) { | ||
// Could not determine the type, skip this field | ||
console.warn(`Could not determine the type for attribute '${attributeName}' of ${pgCodec.name}`); | ||
return; | ||
} | ||
const fieldSpec = { | ||
@@ -196,2 +191,9 @@ description: attribute.description, | ||
hooks: { | ||
build(build) { | ||
return build.extend(build, { | ||
pgResolveOutputType(codec, notNull) { | ||
return resolveOutputType(build, codec, notNull); | ||
}, | ||
}, "Adding helpers from PgAttributesPlugin"); | ||
}, | ||
GraphQLInterfaceType_fields(fields, build, context) { | ||
@@ -198,0 +200,0 @@ const { scope: { pgCodec, pgPolymorphism }, } = context; |
{ | ||
"name": "graphile-build-pg", | ||
"version": "5.0.0-alpha.17", | ||
"version": "5.0.0-alpha.18", | ||
"description": "PostgreSQL plugins for Graphile Build - build a supercharged GraphQL schema by reflection over a PostgreSQL database and executed by Grafast.", | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1037041
11146
3