Skip to content

Commit

Permalink
TypeScript v5
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Apr 6, 2023
1 parent 75a1e62 commit aa21847
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"typedoc": "0.23.28",
"typedoc-plugin-markdown": "3.14.0",
"typedoc-plugin-rename-defaults": "0.6.4",
"typescript": "4.9.5",
"typescript": "5.0.3",
"weak-napi": "2.0.2"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-execute/src/mergeRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function prefixRequest(prefix: string, request: ExecutionRequest): ExecutionRequ
}) as DocumentNode;
}

const prefixedVariables = {};
const prefixedVariables: Record<string, any> = {};

for (const variableName of executionVariableNames) {
prefixedVariables[prefix + variableName] = executionVariables[variableName];
Expand Down
2 changes: 1 addition & 1 deletion packages/delegate/src/finalizeGatewayRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function finalizeGatewayRequest<TContext>(

const { usedVariables, newDocument } = finalizeGatewayDocument(targetSchema, fragments, operations);

const newVariables = {};
const newVariables: Record<string, any> = {};
if (variables != null) {
for (const variableName of usedVariables) {
const variableValue = variables[variableName];
Expand Down
2 changes: 1 addition & 1 deletion packages/delegate/src/mergeFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function executeDelegationStage(
}
if (source instanceof Error || source == null) {
const { fields } = collectFields(schema, EMPTY_OBJECT, EMPTY_OBJECT, type, selectionSet);
const nullResult = {};
const nullResult: Record<string, any> = {};
for (const [responseKey, fieldNodes] of fields) {
const combinedPath = [...path, responseKey];
if (source instanceof GraphQLError) {
Expand Down
1 change: 1 addition & 0 deletions packages/delegate/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ export interface ExternalObject<TContext = Record<string, any>> {
[OBJECT_SUBSCHEMA_SYMBOL]: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
[FIELD_SUBSCHEMA_MAP_SYMBOL]: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, TContext>>;
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
[key: string]: unknown;
}
3 changes: 1 addition & 2 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"value-or-promise": "1.0.12"
},
"devDependencies": {
"graphql": "^16.6.0",
"typescript": "4.9.5"
"graphql": "^16.6.0"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/executor/src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,14 @@ function getStreamValues(
const stream = getDirectiveValues(GraphQLStreamDirective, fieldNodes[0], exeContext.variableValues) as {
initialCount: number;
label: string;
if?: boolean;
};

if (!stream) {
return;
}

if (stream['if'] === false) {
if (stream.if === false) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/load/src/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const OPERATION_KINDS: KindList = [Kind.OPERATION_DEFINITION, Kind.FRAGME
* Kinds of AST nodes that are included in type system definition documents
*/
export const NON_OPERATION_KINDS: KindList = Object.keys(Kind)
.reduce((prev, v) => [...prev, Kind[v]], [] as KindList)
.reduce((prev, v) => [...prev, (Kind as any)[v]], [] as KindList)
.filter(v => !OPERATION_KINDS.includes(v));

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/prisma/src/prisma-yml/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Variables } from './Variables.js';
import { Args } from './types/common.js';
import { Output, IOutput } from './Output.js';

const cache = {};
const cache: Record<string, any> = {};

export async function readDefinition(
filePath: string,
Expand Down
14 changes: 7 additions & 7 deletions packages/loaders/url/tests/url-loader-browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('[url-loader] webpack bundle compat', () => {

it('can be exposed as a global', async () => {
const result = await page.evaluate(async () => {
return typeof window['GraphQLToolsUrlLoader'];
return typeof (window as any)['GraphQLToolsUrlLoader'];
});
expect(result).toEqual('object');
});
Expand All @@ -187,7 +187,7 @@ describe('[url-loader] webpack bundle compat', () => {

const result = await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql');
const result = await executor({
Expand All @@ -212,7 +212,7 @@ describe('[url-loader] webpack bundle compat', () => {

const results = await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql');
const result = await executor({
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('[url-loader] webpack bundle compat', () => {

const results = await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql');
const result = await executor({
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('[url-loader] webpack bundle compat', () => {

const result = await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql', {
subscriptionsProtocol: module.SubscriptionProtocol.SSE,
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('[url-loader] webpack bundle compat', () => {

const result = await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql', {
subscriptionsProtocol: module.SubscriptionProtocol.SSE,
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('[url-loader] webpack bundle compat', () => {

await page.evaluate(
async (httpAddress, document) => {
const module = window['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const module = (window as any)['GraphQLToolsUrlLoader'] as typeof UrlLoaderModule;
const loader = new module.UrlLoader();
const executor = loader.getExecutorAsync(httpAddress + '/graphql');
const result = (await executor({
Expand Down
11 changes: 4 additions & 7 deletions packages/loaders/url/tests/url-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SubscriptionServer } from 'subscriptions-transport-ws';
import { defaultAsyncFetch } from '../src/defaultAsyncFetch.js';
import { Response, Headers } from '@whatwg-node/fetch';
import { loadSchema } from '@graphql-tools/load';
import { testUrl, testSchema, testTypeDefs, assertNonMaybe } from './test-utils';
import { testUrl, testSchema, testTypeDefs, assertNonMaybe, assertAsyncIterable } from './test-utils';
import { execute, isIncrementalResult, subscribe } from '@graphql-tools/executor';
import { AsyncFetchFn } from '@graphql-tools/executor-http';

Expand Down Expand Up @@ -381,8 +381,7 @@ describe('Schema URL Loader', () => {
contextValue: {},
})) as AsyncIterableIterator<ExecutionResult>;

expect(asyncIterator['errors']).toBeFalsy();
expect(asyncIterator['errors']?.length).toBeFalsy();
assertAsyncIterable(asyncIterator);

async function getNextResult() {
const result = await asyncIterator.next();
Expand Down Expand Up @@ -445,8 +444,7 @@ describe('Schema URL Loader', () => {
contextValue: {},
})) as AsyncIterableIterator<ExecutionResult>;

expect(asyncIterator['errors']).toBeFalsy();
expect(asyncIterator['errors']?.length).toBeFalsy();
assertAsyncIterable(asyncIterator);

async function getNextResult() {
const result = await asyncIterator.next();
Expand Down Expand Up @@ -504,8 +502,7 @@ describe('Schema URL Loader', () => {
contextValue: {},
})) as AsyncIterable<ExecutionResult<any>>;

expect(asyncIterable['errors']).toBeFalsy();
expect(asyncIterable['errors']?.length).toBeFalsy();
assertAsyncIterable(asyncIterable);

let i = 0;
for await (const result of asyncIterable) {
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type BaseLoaderOptions = GraphQLParseOptions &
BuildSchemaOptions & {
cwd?: string;
ignore?: string | string[];
includeSources?: boolean;
};

export type WithList<T> = T | T[];
Expand Down
11 changes: 9 additions & 2 deletions packages/wrap/src/transforms/MoveRootField.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { GraphQLFieldConfigMap, GraphQLObjectType, GraphQLSchema, Kind, OperationTypeNode, visit } from 'graphql';
import { ExecutionRequest, ExecutionResult, MapperKind, getRootTypeMap, mapSchema } from '@graphql-tools/utils';
import {
ExecutionRequest,
ExecutionResult,
MapperKind,
getDefinedRootType,
getRootTypeMap,
mapSchema,
} from '@graphql-tools/utils';
import { DelegationContext, Transform } from '@graphql-tools/delegate';

const defaultRootTypeNames = {
Expand Down Expand Up @@ -92,7 +99,7 @@ export class MoveRootField implements Transform {
if (result.data?.__typename) {
const newOperation = this.to[delegationContext.operation][delegationContext.fieldName];
if (newOperation && newOperation !== delegationContext.operation) {
result.data.__typename = delegationContext.targetSchema.getRootType(newOperation)?.name;
result.data.__typename = getDefinedRootType(delegationContext.targetSchema, newOperation)?.name;
}
}
return result;
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

"suppressImplicitAnyIndexErrors": true,

"ignoreDeprecations": "5.0",

"skipLibCheck": true,

"strict": true,
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@theguild/tailwind-config": "0.2.1",
"@types/node": "18.14.6",
"@types/react": "18.0.28",
"typescript": "4.9.5"
"typescript": "5.0.3"
},
"dependencies": {
"@theguild/components": "4.5.9",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11807,10 +11807,10 @@ typedoc@0.23.28:
minimatch "^7.1.3"
shiki "^0.14.1"

typescript@4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
typescript@5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.3.tgz#fe976f0c826a88d0a382007681cbb2da44afdedf"
integrity sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==

ua-parser-js@^0.7.18:
version "0.7.33"
Expand Down

0 comments on commit aa21847

Please sign in to comment.