Skip to content

Commit

Permalink
fix: Typescript errors (#14037)
Browse files Browse the repository at this point in the history
* fix: Typescript errors

* Fix test errors
  • Loading branch information
stocaaro authored Dec 4, 2024
1 parent fb8dadb commit c72e72a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/api-graphql/src/internals/v6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CustomHeaders } from '@aws-amplify/data-schema/runtime';

import { GraphQLAPI } from '../GraphQLAPI';
import {
GraphQLOptions,
GraphQLOptionsV6,
GraphQLResponseV6,
V6Client,
Expand Down Expand Up @@ -113,10 +114,11 @@ export function graphql<
* Neither of these can actually be validated at runtime. Hence, we don't perform
* any validation or type-guarding here.
*/

const result = GraphQLAPI.graphql(
// TODO: move V6Client back into this package?
internals.amplify as any,
options,
options as GraphQLOptions,
headers,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export type GraphQLOperation = Source | string;
export interface GraphQLOptionsV6<
FALLBACK_TYPES = unknown,
TYPED_GQL_STRING extends string = string,
> {
> extends Record<string, unknown> {
query: TYPED_GQL_STRING | DocumentNode;
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
authMode?: GraphQLAuthMode;
Expand Down
12 changes: 10 additions & 2 deletions packages/datastore/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ export type TypeConstructorMap = Record<
export declare const __identifierBrand__: unique symbol;
export type IdentifierBrand<T, K> = T & { [__identifierBrand__]: K };

interface GenericIdentifier {
field: any;
}

// datastore generates a uuid for you
export type ManagedIdentifier<T, F extends keyof T> = IdentifierBrand<
{ field: F extends string ? F : never; type: T },
Expand Down Expand Up @@ -548,7 +552,9 @@ export type IdentifierFields<
infer B
>
? B[number] // B[number]
: MetadataOrDefault<T, M>['identifier']['field']) &
: MetadataOrDefault<T, M>['identifier'] extends GenericIdentifier
? MetadataOrDefault<T, M>['identifier']['field']
: unknown) &
string;

export type IdentifierFieldsForInit<
Expand Down Expand Up @@ -710,7 +716,9 @@ export type IdentifierFieldValue<
? MetadataOrDefault<T, M>['identifier']['fields'] extends [any]
? T[MetadataOrDefault<T, M>['identifier']['fields'][0]]
: never
: T[MetadataOrDefault<T, M>['identifier']['field']];
: MetadataOrDefault<T, M>['identifier'] extends GenericIdentifier
? T[MetadataOrDefault<T, M>['identifier']['field']]
: unknown;

export type IdentifierFieldOrIdentifierObject<
T extends PersistentModel,
Expand Down

0 comments on commit c72e72a

Please sign in to comment.