Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump @types/node from 18.7.1 to 20.11.6 #61

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@deepkit-modules/nx-webpack-plugin": "^0.2.12",
"@deepkit/postgres": "1.0.1-alpha.113",
"@deepkit/type-compiler": "1.0.1-alpha.112",
"@graphql-tools/schema": "^10.0.2",
"@nx/devkit": "^16.8.0",
"@nx/esbuild": "16.7.4",
"@nx/eslint-plugin": "16.7.4",
Expand All @@ -25,7 +26,7 @@
"@release-it/bumper": "^5.1.0",
"@release-it/conventional-changelog": "^7.0.1",
"@types/jest": "^29.4.0",
"@types/node": "~18.7.1",
"@types/node": "~20.11.6",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"commitlint": "^17.7.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"graphql-scalars": "1.22.2",
"@graphql-tools/schema": "10.0.2",
"tslib": "2.6.2"
},
"peerDependencies": {
Expand All @@ -19,8 +20,8 @@
"@deepkit/http": "^1.0.1-alpha.113",
"@deepkit/type": "^1.0.1-alpha.113",
"@deepkit/broker": "^1.0.1-alpha.113",
"rxjs": "^7.8.1",
"@deepkit/injector": "^1.0.1-alpha.113"
"@deepkit/injector": "^1.0.1-alpha.113",
"rxjs": "^7.8.1"
},
"publishConfig": {
"access": "public"
Expand Down
34 changes: 17 additions & 17 deletions packages/core/src/lib/decorators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { graphql } from './decorators';
import { buildSchema } from './schema-builder';
import { Resolvers } from './resolvers';
import { Context, GraphQLMiddleware, Parent } from './types';
import { Context, GraphQLContext, GraphQLMiddleware, Parent } from './types';

/*test('invalid return type for mutation', () => {
expect(() => {
Expand Down Expand Up @@ -75,11 +75,11 @@ test('middleware errors', async () => {
{ controller: TestResolver, module: injectorContext.rootModule },
]);

const schema = buildSchema(resolvers, injectorContext);
const schema = buildSchema(resolvers);

await executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `{ get }`,
});

Expand Down Expand Up @@ -120,11 +120,11 @@ test('resolver middleware is invoked', async () => {
{ controller: TestResolver, module: injectorContext.rootModule },
]);

const schema = buildSchema(resolvers, injectorContext);
const schema = buildSchema(resolvers);

await executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `{ get }`,
});

Expand Down Expand Up @@ -165,11 +165,11 @@ test('query middleware is invoked', async () => {
{ controller: TestResolver, module: injectorContext.rootModule },
]);

const schema = buildSchema(resolvers, injectorContext);
const schema = buildSchema(resolvers);

await executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `{ get }`,
});

Expand Down Expand Up @@ -210,11 +210,11 @@ test('mutation middleware is invoked', async () => {
{ controller: TestResolver, module: injectorContext.rootModule },
]);

const schema = buildSchema(resolvers, injectorContext);
const schema = buildSchema(resolvers);

await executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `mutation { create }`,
});

Expand Down Expand Up @@ -255,11 +255,11 @@ test('subscription middleware is invoked', async () => {
{ controller: TestResolver, module: injectorContext.rootModule },
]);

const schema = buildSchema(resolvers, injectorContext);
const schema = buildSchema(resolvers);

await executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `subscription { create }`,
});

Expand Down Expand Up @@ -298,7 +298,7 @@ test('mutation', async () => {
await expect(
executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `mutation { createUser(data: { username: "Test" }) { id } }`,
}),
).resolves.toMatchSnapshot();
Expand Down Expand Up @@ -329,7 +329,7 @@ test('query', async () => {
await expect(
executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `{ getUser(id: 1) { id } }`,
rootValue: {},
}),
Expand Down Expand Up @@ -364,7 +364,7 @@ test('mutation args validation', async () => {

await expect(
executeGraphQL({
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `mutation { createUser(data: { username: "Test" }) { username } }`,
schema,
}),
Expand Down Expand Up @@ -403,7 +403,7 @@ test.skip('Context', async () => {

await expect(
executeGraphQL({
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `
{
info {
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('resolveField', () => {
await expect(
executeGraphQL({
schema,
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `
{
getUser(id: "9f617521-b9c2-4ab9-a339-3c551c799027") {
Expand Down Expand Up @@ -529,7 +529,7 @@ describe('resolveField', () => {

await expect(
executeGraphQL({
contextValue: { injectorContext },
contextValue: <GraphQLContext>{ injectorContext },
source: `
{
getUser(id: "398cdf36-e3ac-475c-90aa-c70f99add874") {
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/lib/schema-builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReceiveType, resolveReceiveType, Type } from '@deepkit/type';
import { ClassType } from '@deepkit/core';
import { InjectorContext, InjectorModule } from '@deepkit/injector';
import { mergeSchemas } from '@graphql-tools/schema';
import {
GraphQLFieldConfigMap,
GraphQLNamedType,
Expand All @@ -17,29 +17,25 @@ import { GraphQLContext } from './types';
export interface SchemaBuilderOptions {
readonly inputTypes?: readonly Type[];
readonly outputTypes?: readonly Type[];
readonly schemas?: readonly GraphQLSchema[];
}

export function buildSchema(
resolvers: Resolvers,
injectorContext: InjectorContext = new InjectorContext(new InjectorModule()),
options?: SchemaBuilderOptions,
): GraphQLSchema {
return new SchemaBuilder(resolvers, injectorContext, options).build();
return new SchemaBuilder(resolvers, options).build();
}

export class SchemaBuilder {
private readonly inputTypes = new Set<Type>(this.options?.inputTypes);

private readonly outputTypes = new Set<Type>(this.options?.outputTypes);

private readonly typesBuilder = new TypesBuilder(
this.resolvers,
this.injectorContext,
);
private readonly typesBuilder = new TypesBuilder(this.resolvers,);

constructor(
private readonly resolvers: Resolvers,
private readonly injectorContext: InjectorContext,
private readonly options?: SchemaBuilderOptions,
) {}

Expand Down Expand Up @@ -194,11 +190,15 @@ export class SchemaBuilder {
const subscription = this.buildRootSubscriptionType();
const types = [...this.buildInputTypes(), ...this.buildOutputTypes()];

return new GraphQLSchema({
const schema = new GraphQLSchema({
query,
mutation,
subscription,
types,
});

if (!this.options?.schemas?.length) return schema;

return mergeSchemas({ schemas: [schema, ...this.options.schemas] });
}
}
5 changes: 2 additions & 3 deletions packages/core/src/lib/types-builder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLEnumType, GraphQLID, GraphQLUnionType } from 'graphql';
import { InjectorContext, InjectorModule } from '@deepkit/injector';
import { InjectorContext } from '@deepkit/injector';
import {
BrokerBus,
BrokerBusChannel,
Expand Down Expand Up @@ -49,7 +49,7 @@ import {

import { TypesBuilder } from './types-builder';
import { GraphQLContext, ID } from './types';
import { Resolver, Resolvers } from './resolvers';
import { Resolvers } from './resolvers';
import { isAsyncIterable } from './utils';
import { InvalidSubscriptionTypeError } from './errors';

Expand All @@ -59,7 +59,6 @@ describe('TypesBuilder', () => {
beforeEach(() => {
builder = new TypesBuilder(
new Resolvers([]),
new InjectorContext(new InjectorModule()),
);
});

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/lib/types-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ export class TypesBuilder {

private readonly inputObjectTypes = new Map<string, GraphQLInputObjectType>();

constructor(
private readonly resolvers: Resolvers,
private readonly injectorContext: InjectorContext,
) {}
constructor(private readonly resolvers: Resolvers) {}

getScalarType(type: Type): GraphQLScalarType {
if (type.typeName === 'ID') return GraphQLID;
Expand Down
Loading
Loading