Skip to content

Commit

Permalink
Merge pull request #662 from contember/fix/graphql-client-types
Browse files Browse the repository at this point in the history
Fix graphql client types
  • Loading branch information
matej21 authored Jan 15, 2024
2 parents 504ddf9 + 78f63e6 commit 7ddf4dd
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 17 deletions.
41 changes: 37 additions & 4 deletions build/api/client-content.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,24 @@ export namespace ContentClientInput {
export type AnyOrderBy = Input.OrderBy<`${Input.OrderDirection}`>[];
// (undocumented)
export type ConnectOrCreateInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly connect: UniqueWhere<TEntity>;
readonly create: CreateDataInput<TEntity>;
};
// (undocumented)
export type ConnectOrCreateRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly connectOrCreate: ConnectOrCreateInput<TEntity>;
};
// (undocumented)
export type ConnectRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly connect: UniqueWhere<TEntity>;
};
// (undocumented)
export type CreateDataInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
} & {
readonly [key in keyof TEntity['columns']]?: TEntity['columns'][key];
} & {
readonly [key in keyof TEntity['hasMany']]?: CreateManyRelationInput<TEntity['hasMany'][key]>;
Expand All @@ -62,6 +67,7 @@ export namespace ContentClientInput {
};
// (undocumented)
export type CreateInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly data: CreateDataInput<TEntity>;
};
// (undocumented)
Expand All @@ -70,31 +76,39 @@ export namespace ContentClientInput {
export type CreateOneRelationInput<TEntity extends EntityTypeLike> = ConnectRelationInput<TEntity> | CreateRelationInput<TEntity> | ConnectOrCreateRelationInput<TEntity>;
// (undocumented)
export type CreateRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly create: CreateDataInput<TEntity>;
};
// (undocumented)
export type DeleteInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly by: UniqueWhere<TEntity>;
readonly filter?: Where<TEntity>;
};
// (undocumented)
export type DeleteRelationInput = {
export type DeleteRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly delete: true;
};
// (undocumented)
export type DeleteSpecifiedRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly delete: UniqueWhere<TEntity>;
};
// (undocumented)
export type DisconnectRelationInput = {
export type DisconnectRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly disconnect: true;
};
// (undocumented)
export type DisconnectSpecifiedRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly disconnect: UniqueWhere<TEntity>;
};
// (undocumented)
export type FieldOrderBy<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
} & {
readonly [key in keyof TEntity['columns']]?: `${Input.OrderDirection}` | null;
} & {
readonly [key in keyof TEntity['hasMany']]?: FieldOrderBy<TEntity['hasMany'][key]> | null;
Expand All @@ -103,6 +117,7 @@ export namespace ContentClientInput {
};
// (undocumented)
export type HasManyByRelationInput<TEntity extends EntityTypeLike, TUnique extends JSONObject> = {
readonly __typeGuard?: TEntity['name'];
readonly by: TUnique;
readonly filter?: Where<TEntity>;
};
Expand All @@ -112,36 +127,45 @@ export namespace ContentClientInput {
export type HasManyRelationPaginateInput<TEntity extends EntityTypeLike> = PaginationQueryInput<TEntity>;
// (undocumented)
export type HasOneRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly filter?: Where<TEntity>;
};
// (undocumented)
export type ListQueryInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly filter?: Where<TEntity>;
readonly orderBy?: readonly OrderBy<TEntity>[];
readonly offset?: number;
readonly limit?: number;
};
// (undocumented)
export type OrderBy<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly _random?: boolean;
readonly _randomSeeded?: number;
} & FieldOrderBy<TEntity>;
// (undocumented)
export type PaginationQueryInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly filter?: Where<TEntity>;
readonly orderBy?: readonly OrderBy<TEntity>[];
readonly skip?: number;
readonly first?: number;
};
// (undocumented)
export type UniqueQueryInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly by: UniqueWhere<TEntity>;
readonly filter?: Where<TEntity>;
};
// (undocumented)
export type UniqueWhere<TEntity extends EntityTypeLike> = TEntity['unique'];
export type UniqueWhere<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
} & TEntity['unique'];
// (undocumented)
export type UpdateDataInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
} & {
readonly [key in keyof TEntity['columns']]?: TEntity['columns'][key];
} & {
readonly [key in keyof TEntity['hasMany']]?: UpdateManyRelationInput<TEntity['hasMany'][key]>;
Expand All @@ -150,6 +174,7 @@ export namespace ContentClientInput {
};
// (undocumented)
export type UpdateInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly by: UniqueWhere<TEntity>;
readonly filter?: Where<TEntity>;
readonly data: UpdateDataInput<TEntity>;
Expand All @@ -159,34 +184,39 @@ export namespace ContentClientInput {
// (undocumented)
export type UpdateManyRelationInputItem<TEntity extends EntityTypeLike> = CreateRelationInput<TEntity> | ConnectRelationInput<TEntity> | ConnectOrCreateRelationInput<TEntity> | DeleteSpecifiedRelationInput<TEntity> | DisconnectSpecifiedRelationInput<TEntity> | UpdateSpecifiedRelationInput<TEntity> | UpsertSpecifiedRelationInput<TEntity>;
// (undocumented)
export type UpdateOneRelationInput<TEntity extends EntityTypeLike> = CreateRelationInput<TEntity> | ConnectRelationInput<TEntity> | ConnectOrCreateRelationInput<TEntity> | DeleteRelationInput | DisconnectRelationInput | UpdateRelationInput<TEntity> | UpsertRelationInput<TEntity>;
export type UpdateOneRelationInput<TEntity extends EntityTypeLike> = CreateRelationInput<TEntity> | ConnectRelationInput<TEntity> | ConnectOrCreateRelationInput<TEntity> | DeleteRelationInput<TEntity> | DisconnectRelationInput<TEntity> | UpdateRelationInput<TEntity> | UpsertRelationInput<TEntity>;
// (undocumented)
export type UpdateRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly update: UpdateDataInput<TEntity>;
};
// (undocumented)
export type UpdateSpecifiedRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly update: {
readonly by: UniqueWhere<TEntity>;
readonly data: UpdateDataInput<TEntity>;
};
};
// (undocumented)
export type UpsertInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly by: UniqueWhere<TEntity>;
readonly filter?: Where<TEntity>;
readonly update: UpdateDataInput<TEntity>;
readonly create: CreateDataInput<TEntity>;
};
// (undocumented)
export type UpsertRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly upsert: {
readonly update: UpdateDataInput<TEntity>;
readonly create: CreateDataInput<TEntity>;
};
};
// (undocumented)
export type UpsertSpecifiedRelationInput<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly upsert: {
readonly by: UniqueWhere<TEntity>;
readonly update: UpdateDataInput<TEntity>;
Expand All @@ -195,6 +225,7 @@ export namespace ContentClientInput {
};
// (undocumented)
export type Where<TEntity extends EntityTypeLike> = {
readonly __typeGuard?: TEntity['name'];
readonly and?: (readonly (Where<TEntity>)[]) | null;
readonly or?: (readonly (Where<TEntity>)[]) | null;
readonly not?: Where<TEntity> | null;
Expand Down Expand Up @@ -497,6 +528,8 @@ export interface TypedEntitySelection<TSchema extends SchemaTypeLike, TEntityNam
}, TNestedKey extends keyof TEntity['hasOne'] & string, TAlias extends string | null = null>(name: TNestedKey, fields: TypedEntitySelectionCallback<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue> | TypedEntitySelection<TSchema, TEntity['hasOne'][TNestedKey]['name'], TEntity['hasOne'][TNestedKey], TNestedValue>): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
[key in TAlias extends null ? TNestedKey : TAlias]: TNestedValue | null;
}>;
// @internal (undocumented)
readonly context: ContentEntitySelectionContext<TEntityName>;
}

// @public (undocumented)
Expand Down
4 changes: 4 additions & 0 deletions packages/client-content/src/nodes/TypedEntitySelection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EntityTypeLike, SchemaTypeLike } from '../types/Schema'
import { ContentClientInput } from '../types'
import { ContentEntitySelectionContext } from './ContentEntitySelection'

export type TypedEntitySelectionCallback<
TSchema extends SchemaTypeLike,
Expand All @@ -10,6 +11,9 @@ export type TypedEntitySelectionCallback<

export interface TypedEntitySelection<TSchema extends SchemaTypeLike, TEntityName extends string, TEntity extends EntityTypeLike, TValue> {

/** @internal */
readonly context: ContentEntitySelectionContext<TEntityName>,

$$(): TypedEntitySelection<TSchema, TEntityName, TEntity, TValue & {
[key in keyof TEntity['columns']]: TEntity['columns'][key]
}>
Expand Down
Loading

0 comments on commit 7ddf4dd

Please sign in to comment.