@pothos/plugin-simple-objects
Advanced tools
Comparing version 3.7.1 to 4.0.0-next.0
# Change Log | ||
## 4.0.0-next.0 | ||
### Major Changes | ||
- 29841a8: Release Pothos v4 🎉 see https://pothos-graphql.dev/docs/migrations/v4 for more details | ||
### Patch Changes | ||
- Updated dependencies [29841a8] | ||
- @pothos/core@4.0.0-next.0 | ||
## 3.7.1 | ||
@@ -4,0 +15,0 @@ |
@@ -10,4 +10,4 @@ import { FieldMap, FieldNullability, InputFieldMap, InterfaceFieldsShape, InterfaceParam, Normalize, ObjectFieldsShape, ParentShape, SchemaTypes, TypeParam } from '@pothos/core'; | ||
interface SchemaBuilder<Types extends SchemaTypes> { | ||
simpleObject: <Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape extends Normalize<OutputShapeFromFields<Fields> & ParentShape<Types, Interfaces[number]>>>(name: string, options: SimpleObjectTypeOptions<Types, Interfaces, Fields, Shape>, fields?: ObjectFieldsShape<Types, Shape>) => ObjectRef<Shape>; | ||
simpleInterface: <Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<SchemaTypes>[]>(name: string, options: SimpleInterfaceTypeOptions<Types, Fields, Shape, Interfaces>, fields?: InterfaceFieldsShape<Types, Shape>) => InterfaceRef<Shape>; | ||
simpleObject: <Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape extends Normalize<OutputShapeFromFields<Fields> & ParentShape<Types, Interfaces[number]>>>(name: string, options: SimpleObjectTypeOptions<Types, Interfaces, Fields, Shape>, fields?: ObjectFieldsShape<Types, Shape>) => ObjectRef<Types, Shape>; | ||
simpleInterface: <Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<Types>[]>(name: string, options: SimpleInterfaceTypeOptions<Types, Fields, Shape, Interfaces>, fields?: InterfaceFieldsShape<Types, Shape>) => InterfaceRef<Types, Shape>; | ||
} | ||
@@ -19,4 +19,4 @@ interface PothosKindToGraphQLType { | ||
interface FieldOptionsByKind<Types extends SchemaTypes, ParentShape, Type extends TypeParam<Types>, Nullable extends FieldNullability<Type>, Args extends InputFieldMap, ResolveShape, ResolveReturnShape> { | ||
SimpleObject: Omit<ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, 'resolve'>; | ||
SimpleInterface: Omit<InterfaceFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, 'resolve'>; | ||
SimpleObject: ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>; | ||
SimpleInterface: InterfaceFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>; | ||
} | ||
@@ -26,3 +26,3 @@ type SimpleObjectTypeOptions<Types extends SchemaTypes, Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape> = Omit<ObjectTypeOptions<Types, Shape> | ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, 'fields'> & { | ||
}; | ||
interface SimpleInterfaceTypeOptions<Types extends SchemaTypes, Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<SchemaTypes>[]> extends Omit<InterfaceTypeOptions<Types, Shape, Interfaces>, 'args' | 'fields'> { | ||
interface SimpleInterfaceTypeOptions<Types extends SchemaTypes, Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<Types>[]> extends Omit<InterfaceTypeOptions<Types, Shape, Interfaces>, 'args' | 'fields'> { | ||
fields?: SimpleObjectFieldsShape<Types, Fields>; | ||
@@ -29,0 +29,0 @@ } |
@@ -1,7 +0,7 @@ | ||
import { FieldMap, FieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
import { FieldMap, GenericFieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
export type SimpleObjectFieldsShape<Types extends SchemaTypes, Fields extends FieldMap> = (t: PothosSchemaTypes.RootFieldBuilder<Types, unknown, 'SimpleObject'>) => Fields; | ||
export type SimpleInterfaceFieldsShape<Types extends SchemaTypes, Fields extends FieldMap> = (t: PothosSchemaTypes.RootFieldBuilder<Types, unknown, 'SimpleInterface'>) => Fields; | ||
export type OutputShapeFromFields<Fields extends FieldMap> = NullableToOptional<{ | ||
[K in keyof Fields]: Fields[K] extends FieldRef<infer T> ? T : never; | ||
[K in keyof Fields]: Fields[K] extends GenericFieldRef<infer T> ? T : never; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -10,4 +10,4 @@ import { FieldMap, FieldNullability, InputFieldMap, InterfaceFieldsShape, InterfaceParam, Normalize, ObjectFieldsShape, ParentShape, SchemaTypes, TypeParam } from '@pothos/core'; | ||
interface SchemaBuilder<Types extends SchemaTypes> { | ||
simpleObject: <Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape extends Normalize<OutputShapeFromFields<Fields> & ParentShape<Types, Interfaces[number]>>>(name: string, options: SimpleObjectTypeOptions<Types, Interfaces, Fields, Shape>, fields?: ObjectFieldsShape<Types, Shape>) => ObjectRef<Shape>; | ||
simpleInterface: <Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<SchemaTypes>[]>(name: string, options: SimpleInterfaceTypeOptions<Types, Fields, Shape, Interfaces>, fields?: InterfaceFieldsShape<Types, Shape>) => InterfaceRef<Shape>; | ||
simpleObject: <Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape extends Normalize<OutputShapeFromFields<Fields> & ParentShape<Types, Interfaces[number]>>>(name: string, options: SimpleObjectTypeOptions<Types, Interfaces, Fields, Shape>, fields?: ObjectFieldsShape<Types, Shape>) => ObjectRef<Types, Shape>; | ||
simpleInterface: <Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<Types>[]>(name: string, options: SimpleInterfaceTypeOptions<Types, Fields, Shape, Interfaces>, fields?: InterfaceFieldsShape<Types, Shape>) => InterfaceRef<Types, Shape>; | ||
} | ||
@@ -19,4 +19,4 @@ interface PothosKindToGraphQLType { | ||
interface FieldOptionsByKind<Types extends SchemaTypes, ParentShape, Type extends TypeParam<Types>, Nullable extends FieldNullability<Type>, Args extends InputFieldMap, ResolveShape, ResolveReturnShape> { | ||
SimpleObject: Omit<ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, "resolve">; | ||
SimpleInterface: Omit<InterfaceFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, "resolve">; | ||
SimpleObject: ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>; | ||
SimpleInterface: InterfaceFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>; | ||
} | ||
@@ -26,3 +26,3 @@ type SimpleObjectTypeOptions<Types extends SchemaTypes, Interfaces extends InterfaceParam<Types>[], Fields extends FieldMap, Shape> = Omit<ObjectTypeOptions<Types, Shape> | ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, "fields"> & { | ||
}; | ||
interface SimpleInterfaceTypeOptions<Types extends SchemaTypes, Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<SchemaTypes>[]> extends Omit<InterfaceTypeOptions<Types, Shape, Interfaces>, "args" | "fields"> { | ||
interface SimpleInterfaceTypeOptions<Types extends SchemaTypes, Fields extends FieldMap, Shape extends OutputShapeFromFields<Fields>, Interfaces extends InterfaceParam<Types>[]> extends Omit<InterfaceTypeOptions<Types, Shape, Interfaces>, "args" | "fields"> { | ||
fields?: SimpleObjectFieldsShape<Types, Fields>; | ||
@@ -29,0 +29,0 @@ } |
@@ -11,18 +11,2 @@ import './global-types.js'; | ||
const ref = new ObjectRef(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t) => { | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key) => { | ||
this.configStore.onFieldUse(fields[key], (config) => { | ||
if (config.kind === "Object") { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent) => parent[key]; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.objectType(ref, options); | ||
@@ -36,18 +20,2 @@ if (extraFields) { | ||
const ref = new InterfaceRef(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t) => { | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key) => { | ||
this.configStore.onFieldUse(fields[key], (config) => { | ||
if (config.kind === "Interface") { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent) => parent[key]; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.interfaceType(ref, options); | ||
@@ -54,0 +22,0 @@ if (extraFields) { |
@@ -1,7 +0,7 @@ | ||
import { FieldMap, FieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
import { FieldMap, GenericFieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
export type SimpleObjectFieldsShape<Types extends SchemaTypes, Fields extends FieldMap> = (t: PothosSchemaTypes.RootFieldBuilder<Types, unknown, "SimpleObject">) => Fields; | ||
export type SimpleInterfaceFieldsShape<Types extends SchemaTypes, Fields extends FieldMap> = (t: PothosSchemaTypes.RootFieldBuilder<Types, unknown, "SimpleInterface">) => Fields; | ||
export type OutputShapeFromFields<Fields extends FieldMap> = NullableToOptional<{ | ||
[K in keyof Fields]: Fields[K] extends FieldRef<infer T> ? T : never; | ||
[K in keyof Fields]: Fields[K] extends GenericFieldRef<infer T> ? T : never; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -70,18 +70,2 @@ "use strict"; | ||
const ref = new _core.ObjectRef(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t)=>{ | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key)=>{ | ||
this.configStore.onFieldUse(fields[key], (config)=>{ | ||
if (config.kind === 'Object') { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent)=>parent[key]; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.objectType(ref, options); | ||
@@ -95,18 +79,2 @@ if (extraFields) { | ||
const ref = new _core.InterfaceRef(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t)=>{ | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key)=>{ | ||
this.configStore.onFieldUse(fields[key], (config)=>{ | ||
if (config.kind === 'Interface') { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent)=>parent[key]; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.interfaceType(ref, options); | ||
@@ -113,0 +81,0 @@ if (extraFields) { |
{ | ||
"name": "@pothos/plugin-simple-objects", | ||
"version": "3.7.1", | ||
"version": "4.0.0-next.0", | ||
"description": "A Pothos plugin for defining objects and interfaces without ts definitions for those types", | ||
@@ -36,13 +36,13 @@ "main": "./lib/index.js", | ||
"access": "public", | ||
"provenance": true | ||
"provenance": false | ||
}, | ||
"peerDependencies": { | ||
"@pothos/core": "*", | ||
"graphql": ">=15.1.0" | ||
"@pothos/core": "4.0.0-next.0", | ||
"graphql": "^16.8.1" | ||
}, | ||
"devDependencies": { | ||
"graphql": "^16.8.1", | ||
"graphql": "^16.9.0", | ||
"graphql-tag": "^2.12.6", | ||
"@pothos/core": "3.41.2", | ||
"@pothos/test-utils": "1.4.9" | ||
"@pothos/core": "4.0.0-next.0", | ||
"@pothos/test-utils": "2.0.0-next.0" | ||
}, | ||
@@ -49,0 +49,0 @@ "gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc", |
@@ -34,3 +34,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
fields?: ObjectFieldsShape<Types, Shape>, | ||
) => ObjectRef<Shape>; | ||
) => ObjectRef<Types, Shape>; | ||
@@ -40,3 +40,3 @@ simpleInterface: < | ||
Shape extends OutputShapeFromFields<Fields>, | ||
Interfaces extends InterfaceParam<SchemaTypes>[], | ||
Interfaces extends InterfaceParam<Types>[], | ||
>( | ||
@@ -46,3 +46,3 @@ name: string, | ||
fields?: InterfaceFieldsShape<Types, Shape>, | ||
) => InterfaceRef<Shape>; | ||
) => InterfaceRef<Types, Shape>; | ||
} | ||
@@ -64,9 +64,18 @@ | ||
> { | ||
SimpleObject: Omit< | ||
ObjectFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, | ||
'resolve' | ||
SimpleObject: ObjectFieldOptions< | ||
Types, | ||
ParentShape, | ||
Type, | ||
Nullable, | ||
Args, | ||
ResolveReturnShape | ||
>; | ||
SimpleInterface: Omit< | ||
InterfaceFieldOptions<Types, ParentShape, Type, Nullable, Args, ResolveReturnShape>, | ||
'resolve' | ||
SimpleInterface: InterfaceFieldOptions< | ||
Types, | ||
ParentShape, | ||
Type, | ||
Nullable, | ||
Args, | ||
ResolveReturnShape | ||
>; | ||
@@ -91,3 +100,3 @@ } | ||
Shape extends OutputShapeFromFields<Fields>, | ||
Interfaces extends InterfaceParam<SchemaTypes>[], | ||
Interfaces extends InterfaceParam<Types>[], | ||
> extends Omit<InterfaceTypeOptions<Types, Shape, Interfaces>, 'args' | 'fields'> { | ||
@@ -94,0 +103,0 @@ fields?: SimpleObjectFieldsShape<Types, Fields>; |
@@ -38,25 +38,4 @@ import './global-types'; | ||
) { | ||
const ref = new ObjectRef<Shape>(name); | ||
const ref = new ObjectRef<SchemaTypes, Shape>(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t) => { | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key) => { | ||
this.configStore.onFieldUse(fields[key], (config) => { | ||
if (config.kind === 'Object') { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent) => | ||
(parent as Record<string, unknown>)[key] as Readonly<unknown>; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.objectType(ref, options as PothosSchemaTypes.ObjectTypeOptions); | ||
@@ -80,25 +59,4 @@ | ||
) { | ||
const ref = new InterfaceRef<Shape>(name); | ||
const ref = new InterfaceRef<SchemaTypes, Shape>(name); | ||
if (options.fields) { | ||
const originalFields = options.fields; | ||
// eslint-disable-next-line no-param-reassign | ||
options.fields = (t) => { | ||
const fields = originalFields(t); | ||
Object.keys(fields).forEach((key) => { | ||
this.configStore.onFieldUse(fields[key], (config) => { | ||
if (config.kind === 'Interface') { | ||
// eslint-disable-next-line no-param-reassign | ||
config.resolve = (parent) => | ||
(parent as Record<string, unknown>)[key] as Readonly<unknown>; | ||
} | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
} | ||
this.interfaceType(ref, options as {}); | ||
@@ -105,0 +63,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { FieldMap, FieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
import { FieldMap, GenericFieldRef, NullableToOptional, SchemaTypes } from '@pothos/core'; | ||
@@ -12,3 +12,3 @@ export type SimpleObjectFieldsShape<Types extends SchemaTypes, Fields extends FieldMap> = ( | ||
export type OutputShapeFromFields<Fields extends FieldMap> = NullableToOptional<{ | ||
[K in keyof Fields]: Fields[K] extends FieldRef<infer T> ? T : never; | ||
[K in keyof Fields]: Fields[K] extends GenericFieldRef<infer T> ? T : never; | ||
}>; |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
39555
364
2