Skip to content

Commit

Permalink
Update GraphQL dependencies (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachkaev authored Jul 11, 2022
1 parent 1beb92c commit c81e2a1
Show file tree
Hide file tree
Showing 78 changed files with 977 additions and 1,310 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"packages/hash/tsconfig",
"sites/hashai",
"sites/hashdev"
],
"nohoist": [
"**/ts-invariant"
]
},
"scripts": {
Expand Down
21 changes: 11 additions & 10 deletions packages/hash/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@
},
"dependencies": {
"@apidevtools/json-schema-ref-parser": "9.0.9",
"@apollo/client": "3.3.21",
"@apollo/client": "3.6.9",
"@aws-sdk/client-s3": "3.38.0",
"@aws-sdk/client-ses": "3.25.0",
"@aws-sdk/credential-provider-node": "3.41.0",
"@aws-sdk/s3-presigned-post": "3.38.0",
"@aws-sdk/s3-request-presigner": "3.38.0",
"@graphql-tools/schema": "8.5.0",
"@hashintel/hash-backend-utils": "0.0.0",
"@hashintel/hash-shared": "0.0.0",
"@snowplow/node-tracker": "3.3.1",
"@types/lodash": "4.14.175",
"@types/redis": "2.8.32",
"ajv": "8.11.0",
"ajv-formats": "2.1.1",
"apollo-datasource": "3.3.0",
"apollo-server-errors": "3.1.0",
"apollo-server-express": "2.25.3",
"apollo-datasource": "3.3.2",
"apollo-server-core": "3.9.0",
"apollo-server-errors": "3.3.1",
"apollo-server-express": "3.9.0",
"app-root-path": "3.0.0",
"blockprotocol": "0.0.10",
"body-parser": "1.19.0",
Expand All @@ -44,8 +46,8 @@
"express": "4.17.1",
"express-session": "1.17.2",
"graphql": "15.5.1",
"graphql-scalars": "1.17.0",
"graphql-tag": "2.12.5",
"graphql-type-json": "0.3.2",
"helmet": "4.6.0",
"hot-shots": "8.5.0",
"html-to-text": "8.0.0",
Expand Down Expand Up @@ -78,16 +80,15 @@
"uuid": "8.3.2"
},
"devDependencies": {
"@graphql-codegen/cli": "1.21.5",
"@graphql-codegen/introspection": "1.18.2",
"@graphql-codegen/typescript": "1.22.1",
"@graphql-codegen/typescript-resolvers": "1.19.2",
"@graphql-codegen/cli": "2.7.0",
"@graphql-codegen/introspection": "2.1.1",
"@graphql-codegen/typescript": "2.6.0",
"@graphql-codegen/typescript-resolvers": "2.6.7",
"@types/app-root-path": "1.2.4",
"@types/connect-pg-simple": "4.2.4",
"@types/cron": "1.7.3",
"@types/dedent": "0.7.0",
"@types/express-session": "1.17.4",
"@types/graphql-type-json": "0.3.2",
"@types/html-to-text": "8.0.1",
"@types/jest": "28.1.4",
"@types/json-schema": "7.0.9",
Expand Down
30 changes: 16 additions & 14 deletions packages/hash/api/src/graphql/createApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { performance } from "perf_hooks";

import {
ApolloServer,
defaultPlaygroundOptions,
makeExecutableSchema,
} from "apollo-server-express";
ApolloServerPluginLandingPageGraphQLPlayground,
ApolloServerPluginLandingPageDisabled,
} from "apollo-server-core";
import { ApolloServer } from "apollo-server-express";
import { makeExecutableSchema } from "@graphql-tools/schema";

import { StatsD } from "hot-shots";
import { Logger } from "@hashintel/hash-backend-utils/logger";
import { SearchAdapter } from "@hashintel/hash-backend-utils/search/adapter";
Expand Down Expand Up @@ -70,18 +72,20 @@ export const createApolloServer = ({
emailTransporter,
uploadProvider,
passport: buildPassportGraphQLMethods(ctx),
logger: logger.child({ requestId: ctx.res.get("x-hash-request-id") }),
logger: logger.child({
requestId: ctx.res.get("x-hash-request-id") ?? "",
}),
}),
// @todo: we may want to disable introspection at some point for production
introspection: true,
debug: true, // required for stack traces to be captured
plugins: [
{
requestDidStart: (ctx) => {
requestDidStart: async (ctx) => {
ctx.logger = ctx.context.logger as Logger;
const startedAt = performance.now();
return {
didResolveOperation: (didResolveOperationCtx) => {
didResolveOperation: async (didResolveOperationCtx) => {
if (didResolveOperationCtx.operationName) {
statsd?.increment(didResolveOperationCtx.operationName, [
"graphql",
Expand Down Expand Up @@ -126,13 +130,11 @@ export const createApolloServer = ({
};
},
},
process.env.NODE_ENV === "production"
? ApolloServerPluginLandingPageDisabled()
: ApolloServerPluginLandingPageGraphQLPlayground({
settings: { "request.credentials": "include" },
}),
],
playground: {
...defaultPlaygroundOptions,
settings: {
...defaultPlaygroundOptions.settings,
"request.credentials": "include",
},
},
});
};
4 changes: 2 additions & 2 deletions packages/hash/api/src/graphql/resolvers/account/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Resolver } from "../../apiTypes.gen";
import { ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";
import { UnresolvedGQLEntity, Account } from "../../../model";

export const accounts: Resolver<
export const accounts: ResolverFn<
Promise<UnresolvedGQLEntity[]>,
{},
GraphQLContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "../../../model";
import {
BlockProperties as GQLBlockProperties,
Resolver,
ResolverFn,
} from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

Expand All @@ -18,12 +18,13 @@ import { GraphQLContext } from "../../context";
*
* @deprecated
*/
export const blockProperties: Resolver<
export const blockProperties: ResolverFn<
Promise<
Omit<GQLBlockProperties, "entity"> & { entity: UnresolvedGQLUnknownEntity }
>,
UnresolvedGQLBlock,
GraphQLContext
GraphQLContext,
{}
> = async ({ accountId, entityId }, _, { dataSources }) => {
const { db } = dataSources;

Expand Down
4 changes: 2 additions & 2 deletions packages/hash/api/src/graphql/resolvers/block/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Entity, UnresolvedGQLEntity } from "../../../model";

import { QueryBlocksArgs, Resolver } from "../../apiTypes.gen";
import { QueryBlocksArgs, ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

export const blocks: Resolver<
export const blocks: ResolverFn<
Promise<UnresolvedGQLEntity[]>,
{},
GraphQLContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ApolloError } from "apollo-server-errors";
import { Block, UnresolvedGQLBlock, UnresolvedGQLEntity } from "../../../model";
import { Resolver } from "../../apiTypes.gen";
import { ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

export const data: Resolver<
export const data: ResolverFn<
Promise<UnresolvedGQLEntity>,
UnresolvedGQLBlock,
GraphQLContext
GraphQLContext,
{}
> = async ({ accountId, entityId }, _, ctx) => {
const { dataSources } = ctx;

Expand Down
9 changes: 7 additions & 2 deletions packages/hash/api/src/graphql/resolvers/embed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import fetch from "node-fetch";
import { ApolloError } from "apollo-server-errors";

import oEmbedData from "oembed-providers/providers.json";
import { Embed, Maybe, QueryEmbedCodeArgs, Resolver } from "../../apiTypes.gen";
import {
Embed,
Maybe,
QueryEmbedCodeArgs,
ResolverFn,
} from "../../apiTypes.gen";

import { GraphQLContext } from "../../context";

Expand Down Expand Up @@ -84,7 +89,7 @@ async function getEmbedResponse({
);
}

export const embedCode: Resolver<
export const embedCode: ResolverFn<
Promise<Embed>,
{},
GraphQLContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
QueryAggregateEntityArgs,
Resolver,
AggregateOperation,
AggregateOperationInput,
QueryAggregateEntityArgs,
ResolverFn,
} from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";
import { Aggregation, Entity, UnresolvedGQLEntity } from "../../../model";
Expand Down Expand Up @@ -51,7 +51,7 @@ export const dbAggregateEntity =
};
};

export const aggregateEntity: Resolver<
export const aggregateEntity: ResolverFn<
Promise<{
results: UnresolvedGQLEntity[];
operation: AggregateOperation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MutationCreateEntityArgs, Resolver } from "../../apiTypes.gen";
import { MutationCreateEntityArgs, ResolverFn } from "../../apiTypes.gen";
import { Entity, UnresolvedGQLEntity } from "../../../model";
import { LoggedInGraphQLContext } from "../../context";

export const createEntity: Resolver<
export const createEntity: ResolverFn<
Promise<UnresolvedGQLEntity>,
{},
LoggedInGraphQLContext,
Expand Down
4 changes: 2 additions & 2 deletions packages/hash/api/src/graphql/resolvers/entity/entities.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Entity, UnresolvedGQLEntity } from "../../../model";
import { validateEntityTypeChoice } from "../../../util";

import { QueryEntitiesArgs, Resolver } from "../../apiTypes.gen";
import { QueryEntitiesArgs, ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

export const entities: Resolver<
export const entities: ResolverFn<
Promise<UnresolvedGQLEntity[]>,
{},
GraphQLContext,
Expand Down
4 changes: 2 additions & 2 deletions packages/hash/api/src/graphql/resolvers/entity/entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ApolloError, UserInputError } from "apollo-server-express";

import { QueryEntityArgs, Resolver } from "../../apiTypes.gen";
import { QueryEntityArgs, ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";
import { UnresolvedGQLEntity, Entity } from "../../../model";

export const entity: Resolver<
export const entity: ResolverFn<
Promise<UnresolvedGQLEntity>,
{},
GraphQLContext,
Expand Down
7 changes: 4 additions & 3 deletions packages/hash/api/src/graphql/resolvers/entity/history.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Resolver, UnknownEntity } from "../../apiTypes.gen";
import { ResolverFn, UnknownEntity } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

export const history: Resolver<
export const history: ResolverFn<
Promise<UnknownEntity["history"]>,
UnknownEntity,
GraphQLContext
GraphQLContext,
{}
> = async (entity, _, { dataSources }) => {
if (!entity.entityId) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { cloneDeep } from "lodash";
import { ApolloError } from "apollo-server-express";

import {
Resolver,
ImpliedEntityHistory,
ImpliedEntityVersion,
QueryGetImpliedEntityHistoryArgs,
QueryGetImpliedEntityVersionArgs,
ResolverFn,
} from "../../apiTypes.gen";
import { LinkedDataDefinition } from "../util";
import { GraphQLContext } from "../../context";
Expand Down Expand Up @@ -56,7 +56,7 @@ const findLink = (params: {
);
};

export const getImpliedEntityHistory: Resolver<
export const getImpliedEntityHistory: ResolverFn<
Promise<ImpliedEntityHistory>,
{},
GraphQLContext,
Expand Down Expand Up @@ -258,7 +258,7 @@ const hydrateRootSubgraph = async (
return entityVersionIdEntityMap.get(rootEntityVersionId)!;
};

export const getImpliedEntityVersion: Resolver<
export const getImpliedEntityVersion: ResolverFn<
Promise<UnresolvedGQLEntity>,
{},
GraphQLContext,
Expand Down
7 changes: 4 additions & 3 deletions packages/hash/api/src/graphql/resolvers/entity/linkGroups.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloError } from "apollo-server-errors";
import { set } from "lodash";
import { Resolver, Entity as GQLEntity, LinkGroup } from "../../apiTypes.gen";
import { Entity as GQLEntity, LinkGroup, ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";
import { Entity, Link } from "../../../model";
import { DbClient } from "../../../db";
Expand Down Expand Up @@ -155,10 +155,11 @@ const mapLinkGroupsObjectToGQLLinkGroups = (
)
.flat(2);

export const linkGroups: Resolver<
export const linkGroups: ResolverFn<
GQLEntity["linkGroups"],
DbUnknownEntity,
GraphQLContext
GraphQLContext,
{}
> = async (sourceEntity, _, { dataSources }) => {
const source = await Entity.getEntity(dataSources.db, {
accountId: sourceEntity.accountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ApolloError } from "apollo-server-express";
import { DbUnknownEntity } from "../../../db/adapter";
import { Entity, UnresolvedGQLLinkedAggregation } from "../../../model";
import { Resolver } from "../../apiTypes.gen";
import { ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";

export const linkedAggregations: Resolver<
export const linkedAggregations: ResolverFn<
Promise<UnresolvedGQLLinkedAggregation[]>,
DbUnknownEntity,
GraphQLContext
GraphQLContext,
{}
> = async ({ accountId, entityId }, _, { dataSources }) => {
const source = await Entity.getEntityLatestVersion(dataSources.db, {
accountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloError } from "apollo-server-errors";
import { Resolver } from "../../apiTypes.gen";
import { ResolverFn } from "../../apiTypes.gen";
import { GraphQLContext } from "../../context";
import { Entity, UnresolvedGQLUnknownEntity } from "../../../model";
import {
Expand All @@ -8,10 +8,11 @@ import {
} from "./linkGroups";
import { DbUnknownEntity } from "../../../db/adapter";

export const linkedEntities: Resolver<
export const linkedEntities: ResolverFn<
Promise<UnresolvedGQLUnknownEntity[]>,
DbUnknownEntity,
GraphQLContext
GraphQLContext,
{}
> = async (entity, _, { dataSources }) => {
const source = await Entity.getEntity(dataSources.db, {
accountId: entity.accountId,
Expand Down
Loading

0 comments on commit c81e2a1

Please sign in to comment.