@homebound/graphql-typescript-simple-resolvers
Advanced tools
Comparing version 1.36.0 to 1.37.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.plugin = void 0; | ||
const change_case_1 = require("change-case"); | ||
const graphql_1 = require("graphql"); | ||
const change_case_1 = require("change-case"); | ||
const ts_poet_1 = require("ts-poet"); | ||
const upper_case_first_1 = require("upper-case-first"); | ||
const ts_poet_1 = require("ts-poet"); | ||
const types_1 = require("./types"); | ||
@@ -43,2 +43,4 @@ const builtInScalarsImps = ["Int", "Boolean", "String", "ID", "Float"]; | ||
generateEachInterfaceResolverType(chunks, config, interfaceToImpls, interfaceTypes); | ||
// Make union types of interfaces | ||
generateInterfaceUnionTypes(chunks, config, interfaceToImpls); | ||
// Make each resolver for any output type, whether its required or optional | ||
@@ -86,2 +88,8 @@ generateEachResolverType(chunks, config, interfaceToImpls, allTypesWithResolvers); | ||
} | ||
// Also add type unions of the possible types for use in code if desired | ||
function generateInterfaceUnionTypes(chunks, config, interfaceToImpls) { | ||
interfaceToImpls.forEach((impls, inter) => chunks.push(ts_poet_1.code ` | ||
export type ${inter.name}Types = ${types_1.joinCodes(impls.map(imp => ts_poet_1.code `${types_1.mapObjectType(config, imp)}`), " | ")}; | ||
`)); | ||
} | ||
function generateEachResolverType(chunks, config, interfaceToImpls, allTypesWithResolvers) { | ||
@@ -88,0 +96,0 @@ const ctx = types_1.toImp(config.contextType); |
@@ -28,2 +28,6 @@ import { Context, AuthorId, Popularity } from "./entities"; | ||
} | ||
export type HasNameTypes = AuthorId | Book; | ||
export type FieldWithArgsTypes = AuthorId | Book; | ||
export interface AuthorResolvers extends HasNameResolvers<AuthorId>, FieldWithArgsResolvers<AuthorId> { | ||
@@ -30,0 +34,0 @@ summary: Resolver<AuthorId, {}, AuthorSummary>; |
{ | ||
"name": "@homebound/graphql-typescript-simple-resolvers", | ||
"version": "1.36.0", | ||
"version": "1.37.0", | ||
"main": "./build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./build/", |
31089
591