graphile-build
Advanced tools
Comparing version 5.0.0-beta.3 to 5.0.0-beta.4
# graphile-build | ||
## 5.0.0-beta.4 | ||
### Patch Changes | ||
- [#454](https://github.com/benjie/crystal/pull/454) | ||
[`196e5c1aa`](https://github.com/benjie/crystal/commit/196e5c1aab52dbe2a069d0a15b9e4931523fd2dd) | ||
Thanks [@benjie](https://github.com/benjie)! - | ||
`@interface mode=single/relational` now get `Node` interface if the table has | ||
a PK. | ||
🚨 `@interface mode=union` no longer gets `Node` interface unless you also add | ||
`@behavior node`. | ||
## 5.0.0-beta.3 | ||
@@ -4,0 +17,0 @@ |
@@ -409,2 +409,7 @@ import type { BaseGraphQLArguments, ExecutableStep, GrafastArgumentConfig, GrafastFieldConfig, GrafastFieldConfigArgumentMap, GrafastInputFieldConfig, GrafastInputFieldConfigMap, OutputPlanForType } from "grafast"; | ||
interface ScopeInterface extends Scope { | ||
/** | ||
* If true, 'AddNoteInterfaceToSuitableTypesPlugin' will add the `Node` | ||
* interface and `id` field automatically to this interface | ||
*/ | ||
supportsNodeInterface?: boolean; | ||
} | ||
@@ -446,3 +451,2 @@ interface ContextInterface extends Context { | ||
interface ScopeUnion extends Scope { | ||
isPgUnionMemberUnion?: boolean; | ||
} | ||
@@ -449,0 +453,0 @@ interface ContextUnion extends Context { |
@@ -24,7 +24,7 @@ "use strict"; | ||
} | ||
const Type = getTypeByName(inflection.builtin("Node")); | ||
if (!Type) { | ||
const NodeInterfaceType = getTypeByName(inflection.builtin("Node")); | ||
if (!NodeInterfaceType) { | ||
return interfaces; | ||
} | ||
return [...interfaces, Type]; | ||
return [...interfaces, NodeInterfaceType]; | ||
}, | ||
@@ -41,4 +41,4 @@ GraphQLObjectType_fields(fields, build, context) { | ||
} | ||
const Type = getTypeByName(inflection.builtin("Node")); | ||
if (!Type) { | ||
const NodeInterfaceType = getTypeByName(inflection.builtin("Node")); | ||
if (!NodeInterfaceType) { | ||
return fields; | ||
@@ -57,4 +57,33 @@ } | ||
}, | ||
}, "Adding id field to Query type from AddNodeInterfaceToQueryPlugin"); | ||
}, `Adding id field to ${Self.name} type from AddNodeInterfaceToQueryPlugin`); | ||
}, | ||
GraphQLInterfaceType_interfaces(interfaces, build, context) { | ||
const { getTypeByName, inflection } = build; | ||
const { scope: { supportsNodeInterface }, } = context; | ||
if (!supportsNodeInterface) { | ||
return interfaces; | ||
} | ||
const NodeInterfaceType = getTypeByName(inflection.builtin("Node")); | ||
if (!NodeInterfaceType) { | ||
return interfaces; | ||
} | ||
return [...interfaces, NodeInterfaceType]; | ||
}, | ||
GraphQLInterfaceType_fields(fields, build, context) { | ||
const { getTypeByName, inflection, graphql: { GraphQLNonNull, GraphQLID }, } = build; | ||
const { Self, scope: { supportsNodeInterface }, } = context; | ||
if (!supportsNodeInterface) { | ||
return fields; | ||
} | ||
const NodeInterfaceType = getTypeByName(inflection.builtin("Node")); | ||
if (!NodeInterfaceType) { | ||
return fields; | ||
} | ||
return build.extend(fields, { | ||
[build.inflection.nodeIdFieldName()]: { | ||
description: build.wrapDescription("A globally unique identifier. Can be used in various places throughout the system to identify this single value.", "field"), | ||
type: new GraphQLNonNull(GraphQLID), | ||
}, | ||
}, `Adding id field to ${Self.name} interface type from AddNodeInterfaceToQueryPlugin`); | ||
}, | ||
}, | ||
@@ -61,0 +90,0 @@ }, |
@@ -67,2 +67,9 @@ "use strict"; | ||
} | ||
const details = build.getTypeMetaByName(typeName); | ||
if (!details) { | ||
throw new Error(`Attempted to register Node ID handler for type '${typeName}', but that type isn't registered (yet)`); | ||
} | ||
if (details.Constructor !== build.graphql.GraphQLObjectType) { | ||
throw new Error(`Attempted to register Node ID handler for type '${typeName}', but that isn't an object type! (constructor: ${details.Constructor.name})`); | ||
} | ||
nodeIdHandlerByTypeName[typeName] = handler; | ||
@@ -69,0 +76,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
export declare const version = "5.0.0-beta.3"; | ||
export declare const version = "5.0.0-beta.4"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is autogenerated by /scripts/postversion.mjs | ||
exports.version = "5.0.0-beta.3"; | ||
exports.version = "5.0.0-beta.4"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "graphile-build", | ||
"version": "5.0.0-beta.3", | ||
"version": "5.0.0-beta.4", | ||
"description": "Build a GraphQL schema from plugins", | ||
@@ -66,3 +66,3 @@ "type": "commonjs", | ||
"@types/jest": "^27.5.1", | ||
"graphile-export": "^0.0.2-beta.1", | ||
"graphile-export": "^0.0.2-beta.2", | ||
"graphql": "16.1.0-experimental-stream-defer.6", | ||
@@ -69,0 +69,0 @@ "jest": "^28.1.3", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
438411
5048