mirror of
https://github.com/wassname/talk.git
synced 2026-06-27 16:32:15 +08:00
[CORL-688] Refactor: Consolidate the tenant and common context together (#2780)
* feat: initial impl * Create preliminary comment moderation slices CORL-688 * Move slices logic into stacks CORL-688 * Create user comment counts CORL-688 * Create naive mutation that initializes user comment counts CORL-688 * Use bulk updates in user counts migration CORL-688 * fix: review * fix: fixed issue with aggregation * Migrate creating comment into stacks CORL-688 * Migrate editing a comment to the stacks CORL-688 * Break publishing comment status out of updateAllCounts CORL-688 * review: removed variable scoping in favor of export * revert: feb8e8196cd448f5cd24f1ca2eb0b91fe9bd43c7 * review: simplification of stacks implementation This simplifies the stacks implementation to better reuse code related to count management and event publishing. This can be used to great effect with the upcomming events PR #2738. * Consolidate the tenant and common context together CORL-688 * review: removed variable scoping in favor of export * revert: feb8e8196cd448f5cd24f1ca2eb0b91fe9bd43c7 * review: simplification of stacks implementation This simplifies the stacks implementation to better reuse code related to count management and event publishing. This can be used to great effect with the upcomming events PR #2738. * fix: check if authorID is null before update user counts CORL-688 * Consolidate common/tenant context supporting files CORL-688 * feat: renamed TenantContext -> GraphContext Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"projects": {
|
||||
"tenant": {
|
||||
"schemaPath": "src/core/server/graph/tenant/schema/schema.graphql"
|
||||
"schemaPath": "src/core/server/graph/schema/schema.graphql"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@
|
||||
"lint:server": "eslint 'src/**/*.{js,ts,tsx}' --ignore-pattern 'src/core/client/**'",
|
||||
"lint:client": "eslint 'src/core/client/**/*.{js,ts,tsx}'",
|
||||
"lint:scripts": "eslint 'scripts/**/*.{js,ts,tsx}'",
|
||||
"lint:graphql": "graphql-schema-linter src/core/server/graph/tenant/schema/schema.graphql",
|
||||
"lint:graphql": "graphql-schema-linter src/core/server/graph/schema/schema.graphql",
|
||||
"lint-fix": "npm run lint:server -- --fix && npm run lint:client -- --fix && npm run lint:scripts -- --fix",
|
||||
"test": "node --trace-warnings scripts/test.js --env=jsdom",
|
||||
"tscheck": "npm-run-all --parallel tscheck:*",
|
||||
@@ -394,7 +394,7 @@
|
||||
"*.{j,t}s{,x}": [
|
||||
"eslint"
|
||||
],
|
||||
"src/core/server/graph/tenant/schema/schema.graphql": [
|
||||
"src/core/server/graph/schema/schema.graphql": [
|
||||
"graphql-schema-linter"
|
||||
],
|
||||
"{src/core/client/stream/events.ts,scripts/generateEventDocs.ts,events.md}": [
|
||||
|
||||
@@ -74,7 +74,7 @@ if (persist) {
|
||||
if (fs.existsSync(persist)) {
|
||||
// Create the new filename.
|
||||
const name = path.basename(program.src);
|
||||
const generated = "./src/core/server/graph/common/persisted/__generated__";
|
||||
const generated = "./src/core/server/graph/persisted/__generated__";
|
||||
|
||||
// Create the generated directory if it doesn't exist.
|
||||
fs.ensureDirSync(generated);
|
||||
|
||||
@@ -12,12 +12,12 @@ async function main() {
|
||||
name: "tenant",
|
||||
fileName: path.join(
|
||||
__dirname,
|
||||
"../src/core/server/graph/tenant/schema/__generated__/types.ts"
|
||||
"../src/core/server/graph/schema/__generated__/types.ts"
|
||||
),
|
||||
config: {
|
||||
contextType: "TenantContext",
|
||||
contextType: "GraphContext",
|
||||
importStatements: [
|
||||
'import TenantContext from "coral-server/graph/tenant/context";',
|
||||
'import GraphContext from "coral-server/graph/context";',
|
||||
'import { Cursor } from "coral-server/models/helpers";',
|
||||
],
|
||||
customScalarType: { Cursor: "Cursor", Time: "Date" },
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
UserForbiddenError,
|
||||
UserNotFoundError,
|
||||
} from "coral-server/errors";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
import { retrieveUser, User } from "coral-server/models/user";
|
||||
import { decodeJWT, extractTokenFromRequest } from "coral-server/services/jwt";
|
||||
import {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { handleSuccessfulLogin } from "coral-server/app/middleware/passport";
|
||||
import { validate } from "coral-server/app/request/body";
|
||||
import { RequestLimiter } from "coral-server/app/request/limiter";
|
||||
import { IntegrationDisabled } from "coral-server/errors";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
import { LocalProfile, User } from "coral-server/models/user";
|
||||
import { create } from "coral-server/services/users";
|
||||
import { sendConfirmationEmail } from "coral-server/services/users/auth";
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { CLIENT_ID_HEADER } from "coral-common/constants";
|
||||
import { AppOptions } from "coral-server/app";
|
||||
import { graphqlMiddleware } from "coral-server/app/middleware/graphql";
|
||||
import TenantContext, {
|
||||
TenantContextOptions,
|
||||
} from "coral-server/graph/tenant/context";
|
||||
import GraphContext, { GraphContextOptions } from "coral-server/graph/context";
|
||||
import { Request, RequestHandler } from "coral-server/types/express";
|
||||
|
||||
export type GraphMiddlewareOptions = Pick<
|
||||
@@ -47,7 +45,7 @@ export const graphQLHandler = ({
|
||||
}
|
||||
|
||||
// Create some new options to store the tenant context details inside.
|
||||
const opts: TenantContextOptions = {
|
||||
const opts: GraphContextOptions = {
|
||||
...options,
|
||||
id,
|
||||
now,
|
||||
@@ -72,7 +70,7 @@ export const graphQLHandler = ({
|
||||
|
||||
return {
|
||||
schema,
|
||||
context: new TenantContext(opts),
|
||||
context: new GraphContext(opts),
|
||||
};
|
||||
},
|
||||
metrics
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
import { create, CreateUser } from "coral-server/services/users";
|
||||
import { Request, RequestHandler } from "coral-server/types/express";
|
||||
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export type TenantInstallCheckHandlerOptions = Pick<
|
||||
AppOptions,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
ErrorWrappingExtension,
|
||||
LoggerExtension,
|
||||
MetricsExtension,
|
||||
} from "coral-server/graph/common/extensions";
|
||||
} from "coral-server/graph/extensions";
|
||||
import { Metrics } from "coral-server/services/metrics";
|
||||
|
||||
// Sourced from: https://github.com/apollographql/apollo-server/blob/958846887598491fadea57b3f9373d129300f250/packages/apollo-server-core/src/ApolloServer.ts#L46-L57
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AppOptions } from "coral-server/app";
|
||||
import { RawQueryNotAuthorized } from "coral-server/errors";
|
||||
import { getPersistedQuery } from "coral-server/graph/common/persisted";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { getPersistedQuery } from "coral-server/graph/persisted";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
import { RequestHandler } from "coral-server/types/express";
|
||||
|
||||
type PersistedQueryMiddlewareOptions = Pick<
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "coral-server/models/user";
|
||||
import { findOrCreate } from "coral-server/services/users";
|
||||
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export type FacebookStrategyOptions = OAuth2StrategyOptions;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "coral-server/models/user";
|
||||
import { findOrCreate } from "coral-server/services/users";
|
||||
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export type GoogleStrategyOptions = OAuth2StrategyOptions;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import { findOrCreate } from "coral-server/services/users";
|
||||
import { validateUsername } from "coral-server/services/users/helpers";
|
||||
import { Request } from "coral-server/types/express";
|
||||
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export interface Params {
|
||||
id_token?: string;
|
||||
|
||||
@@ -27,7 +27,7 @@ import { findOrCreate } from "coral-server/services/users";
|
||||
import {
|
||||
GQLSSOAuthIntegration,
|
||||
GQLUSER_ROLE,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { Verifier } from "../jwt";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Db } from "mongodb";
|
||||
import path from "path";
|
||||
|
||||
import { Config } from "coral-server/config";
|
||||
import { GQLDIGEST_FREQUENCY } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLDIGEST_FREQUENCY } from "coral-server/graph/schema/__generated__/types";
|
||||
import { MailerQueue } from "coral-server/queue/tasks/mailer";
|
||||
import { DigestibleTemplate } from "coral-server/queue/tasks/mailer/templates";
|
||||
import { JWTSigningConfig } from "coral-server/services/jwt";
|
||||
|
||||
@@ -11,7 +11,7 @@ import { reduceSeconds, UNIT } from "coral-common/helpers/i18n";
|
||||
import { translate } from "coral-server/services/i18n";
|
||||
|
||||
import { Writable } from "coral-common/types";
|
||||
import { GQLUSER_AUTH_CONDITIONS } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLUSER_AUTH_CONDITIONS } from "coral-server/graph/schema/__generated__/types";
|
||||
import { ERROR_TRANSLATIONS } from "./translations";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
import { Db } from "mongodb";
|
||||
import uuid from "uuid";
|
||||
|
||||
import { LanguageCode } from "coral-common/helpers/i18n/locales";
|
||||
import { Config } from "coral-server/config";
|
||||
import logger, { Logger } from "coral-server/logger";
|
||||
import { PersistedQuery } from "coral-server/models/queries";
|
||||
import { User } from "coral-server/models/user";
|
||||
import { I18n } from "coral-server/services/i18n";
|
||||
import { AugmentedRedis } from "coral-server/services/redis";
|
||||
import { Request } from "coral-server/types/express";
|
||||
import { RedisPubSub } from "graphql-redis-subscriptions";
|
||||
|
||||
export interface CommonContextOptions {
|
||||
id?: string;
|
||||
now?: Date;
|
||||
user?: User;
|
||||
req?: Request;
|
||||
logger?: Logger;
|
||||
lang?: LanguageCode;
|
||||
disableCaching?: boolean;
|
||||
persisted?: PersistedQuery;
|
||||
config: Config;
|
||||
i18n: I18n;
|
||||
pubsub: RedisPubSub;
|
||||
mongo: Db;
|
||||
redis: AugmentedRedis;
|
||||
}
|
||||
|
||||
export default class CommonContext {
|
||||
public readonly user?: User;
|
||||
public readonly req?: Request;
|
||||
public readonly persisted?: PersistedQuery;
|
||||
public readonly id: string;
|
||||
public readonly config: Config;
|
||||
public readonly i18n: I18n;
|
||||
public readonly lang: LanguageCode;
|
||||
public readonly now: Date;
|
||||
public readonly logger: Logger;
|
||||
public readonly pubsub: RedisPubSub;
|
||||
public readonly mongo: Db;
|
||||
public readonly redis: AugmentedRedis;
|
||||
public readonly disableCaching: boolean;
|
||||
|
||||
constructor({
|
||||
id = uuid.v1(),
|
||||
now = new Date(),
|
||||
logger: log = logger,
|
||||
user,
|
||||
req,
|
||||
persisted,
|
||||
config,
|
||||
i18n,
|
||||
lang = i18n.getDefaultLang(),
|
||||
pubsub,
|
||||
mongo,
|
||||
redis,
|
||||
disableCaching = false,
|
||||
}: CommonContextOptions) {
|
||||
this.id = id;
|
||||
this.logger = log.child(
|
||||
{
|
||||
context: "graph",
|
||||
contextID: id,
|
||||
},
|
||||
true
|
||||
);
|
||||
this.now = now;
|
||||
this.user = user;
|
||||
this.req = req;
|
||||
this.persisted = persisted;
|
||||
this.config = config;
|
||||
this.i18n = i18n;
|
||||
this.lang = lang;
|
||||
this.pubsub = pubsub;
|
||||
this.mongo = mongo;
|
||||
this.redis = redis;
|
||||
this.disableCaching = disableCaching;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface ClientMutationProps {
|
||||
clientMutationId: string;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import { RedisPubSub } from "graphql-redis-subscriptions";
|
||||
import { Db } from "mongodb";
|
||||
import uuid from "uuid";
|
||||
|
||||
import { LanguageCode } from "coral-common/helpers/i18n/locales";
|
||||
import { Config } from "coral-server/config";
|
||||
import {
|
||||
createPublisher,
|
||||
Publisher,
|
||||
} from "coral-server/graph/subscriptions/publisher";
|
||||
import logger, { Logger } from "coral-server/logger";
|
||||
import { PersistedQuery } from "coral-server/models/queries";
|
||||
import { Tenant } from "coral-server/models/tenant";
|
||||
import { User } from "coral-server/models/user";
|
||||
import { MailerQueue } from "coral-server/queue/tasks/mailer";
|
||||
import { NotifierQueue } from "coral-server/queue/tasks/notifier";
|
||||
import { ScraperQueue } from "coral-server/queue/tasks/scraper";
|
||||
import { I18n } from "coral-server/services/i18n";
|
||||
import { JWTSigningConfig } from "coral-server/services/jwt";
|
||||
import { AugmentedRedis } from "coral-server/services/redis";
|
||||
import createSlackPublisher from "coral-server/services/slack/publisher";
|
||||
import TenantCache from "coral-server/services/tenant/cache";
|
||||
import { Request } from "coral-server/types/express";
|
||||
|
||||
import loaders from "./loaders";
|
||||
import mutators from "./mutators";
|
||||
|
||||
export interface GraphContextOptions {
|
||||
clientID?: string;
|
||||
disableCaching?: boolean;
|
||||
id?: string;
|
||||
lang?: LanguageCode;
|
||||
logger?: Logger;
|
||||
now?: Date;
|
||||
persisted?: PersistedQuery;
|
||||
req?: Request;
|
||||
signingConfig?: JWTSigningConfig;
|
||||
user?: User;
|
||||
|
||||
config: Config;
|
||||
i18n: I18n;
|
||||
mailerQueue: MailerQueue;
|
||||
mongo: Db;
|
||||
notifierQueue: NotifierQueue;
|
||||
pubsub: RedisPubSub;
|
||||
redis: AugmentedRedis;
|
||||
scraperQueue: ScraperQueue;
|
||||
tenant: Tenant;
|
||||
tenantCache: TenantCache;
|
||||
}
|
||||
|
||||
export default class GraphContext {
|
||||
public readonly config: Config;
|
||||
public readonly disableCaching: boolean;
|
||||
public readonly i18n: I18n;
|
||||
public readonly id: string;
|
||||
public readonly lang: LanguageCode;
|
||||
public readonly loaders: ReturnType<typeof loaders>;
|
||||
public readonly logger: Logger;
|
||||
public readonly mailerQueue: MailerQueue;
|
||||
public readonly mongo: Db;
|
||||
public readonly mutators: ReturnType<typeof mutators>;
|
||||
public readonly now: Date;
|
||||
public readonly publisher: Publisher;
|
||||
public readonly pubsub: RedisPubSub;
|
||||
public readonly redis: AugmentedRedis;
|
||||
public readonly scraperQueue: ScraperQueue;
|
||||
public readonly tenant: Tenant;
|
||||
public readonly tenantCache: TenantCache;
|
||||
|
||||
public readonly clientID?: string;
|
||||
public readonly persisted?: PersistedQuery;
|
||||
public readonly req?: Request;
|
||||
public readonly signingConfig?: JWTSigningConfig;
|
||||
public readonly user?: User;
|
||||
|
||||
constructor(options: GraphContextOptions) {
|
||||
this.id = options.id || uuid.v1();
|
||||
this.now = options.now || new Date();
|
||||
this.lang = options.lang || options.i18n.getDefaultLang();
|
||||
this.disableCaching = options.disableCaching || false;
|
||||
|
||||
this.logger = (options.logger || logger).child(
|
||||
{ context: "graph", contextID: this.id },
|
||||
true
|
||||
);
|
||||
|
||||
this.user = options.user;
|
||||
this.req = options.req;
|
||||
this.persisted = options.persisted;
|
||||
this.config = options.config;
|
||||
this.i18n = options.i18n;
|
||||
this.pubsub = options.pubsub;
|
||||
this.mongo = options.mongo;
|
||||
this.redis = options.redis;
|
||||
this.tenant = options.tenant;
|
||||
this.tenantCache = options.tenantCache;
|
||||
this.scraperQueue = options.scraperQueue;
|
||||
this.mailerQueue = options.mailerQueue;
|
||||
this.signingConfig = options.signingConfig;
|
||||
this.clientID = options.clientID;
|
||||
|
||||
this.publisher = createPublisher({
|
||||
pubsub: this.pubsub,
|
||||
slackPublisher: createSlackPublisher(
|
||||
this.mongo,
|
||||
this.config,
|
||||
this.tenant
|
||||
),
|
||||
notifierQueue: options.notifierQueue,
|
||||
tenantID: this.tenant.id,
|
||||
clientID: this.clientID,
|
||||
});
|
||||
|
||||
this.loaders = loaders(this);
|
||||
this.mutators = mutators(this);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,7 +6,7 @@ import {
|
||||
UserForbiddenError,
|
||||
UserSuspended,
|
||||
} from "coral-server/errors";
|
||||
import CommonContext from "coral-server/graph/common/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import {
|
||||
consolidateUserStatus,
|
||||
consolidateUserSuspensionStatus,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import {
|
||||
GQLUSER_AUTH_CONDITIONS,
|
||||
GQLUSER_ROLE,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { calculateLocationKey } from "./helpers";
|
||||
|
||||
@@ -64,7 +64,7 @@ const calculateAuthConditionsMemoized = memoize(calculateAuthConditions);
|
||||
|
||||
const auth: DirectiveResolverFn<
|
||||
Record<string, string | undefined>,
|
||||
CommonContext
|
||||
GraphContext
|
||||
> = (
|
||||
next,
|
||||
src,
|
||||
+3
-3
@@ -2,9 +2,9 @@ import { DirectiveResolverFn } from "graphql-tools";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
import { RateLimitExceeded } from "coral-server/errors";
|
||||
import { calculateLocationKey } from "coral-server/graph/common/directives/helpers";
|
||||
import { calculateLocationKey } from "coral-server/graph/directives/helpers";
|
||||
|
||||
import TenantContext from "../context";
|
||||
import GraphContext from "../context";
|
||||
|
||||
export interface RateDirectiveArgs {
|
||||
max?: number;
|
||||
@@ -14,7 +14,7 @@ export interface RateDirectiveArgs {
|
||||
|
||||
const rate: DirectiveResolverFn<
|
||||
Record<string, string | undefined>,
|
||||
TenantContext
|
||||
GraphContext
|
||||
> = async (
|
||||
next,
|
||||
src,
|
||||
+7
-10
@@ -8,12 +8,9 @@ import {
|
||||
InternalDevelopmentError,
|
||||
InternalError,
|
||||
} from "coral-server/errors";
|
||||
import CommonContext from "coral-server/graph/common/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
|
||||
function hoistCoralErrorExtensions(
|
||||
ctx: CommonContext,
|
||||
err: GraphQLError
|
||||
): void {
|
||||
function hoistCoralErrorExtensions(ctx: GraphContext, err: GraphQLError): void {
|
||||
// Grab or wrap the originalError so that it's a CoralError.
|
||||
const originalError = extractOriginalError(err, ctx);
|
||||
if (!originalError) {
|
||||
@@ -44,7 +41,7 @@ function hoistCoralErrorExtensions(
|
||||
*/
|
||||
function extractOriginalError(
|
||||
err: GraphQLError,
|
||||
ctx: CommonContext
|
||||
ctx: GraphContext
|
||||
): CoralError | undefined {
|
||||
if (err instanceof ApolloError) {
|
||||
// ApolloError's don't need to be hoisted as they contain validation
|
||||
@@ -78,7 +75,7 @@ function extractOriginalError(
|
||||
* @param err the error that occurred
|
||||
*/
|
||||
export function enrichError(
|
||||
ctx: CommonContext,
|
||||
ctx: GraphContext,
|
||||
err: GraphQLError
|
||||
): GraphQLError {
|
||||
if (err.extensions) {
|
||||
@@ -97,11 +94,11 @@ export function enrichError(
|
||||
return err;
|
||||
}
|
||||
|
||||
export class ErrorWrappingExtension implements GraphQLExtension<CommonContext> {
|
||||
export class ErrorWrappingExtension implements GraphQLExtension<GraphContext> {
|
||||
public willSendResponse(o: {
|
||||
graphqlResponse: GraphQLResponse;
|
||||
context: CommonContext;
|
||||
}): void | { graphqlResponse: GraphQLResponse; context: CommonContext } {
|
||||
context: GraphContext;
|
||||
}): void | { graphqlResponse: GraphQLResponse; context: GraphContext } {
|
||||
if (o.graphqlResponse.errors) {
|
||||
return {
|
||||
...o,
|
||||
+5
-5
@@ -6,16 +6,16 @@ import {
|
||||
} from "graphql-extensions";
|
||||
import now from "performance-now";
|
||||
|
||||
import CommonContext from "coral-server/graph/common/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
|
||||
import { getOperationMetadata, getPersistedQueryMetadata } from "./helpers";
|
||||
|
||||
export function logError(ctx: CommonContext, err: GraphQLError) {
|
||||
export function logError(ctx: GraphContext, err: GraphQLError) {
|
||||
ctx.logger.error({ err }, "graphql query error");
|
||||
}
|
||||
|
||||
export function logQuery(
|
||||
ctx: CommonContext,
|
||||
ctx: GraphContext,
|
||||
document: DocumentNode,
|
||||
persisted = ctx.persisted,
|
||||
responseTime?: number
|
||||
@@ -38,7 +38,7 @@ export function logQuery(
|
||||
);
|
||||
}
|
||||
|
||||
export class LoggerExtension implements GraphQLExtension<CommonContext> {
|
||||
export class LoggerExtension implements GraphQLExtension<GraphContext> {
|
||||
public executionDidStart(o: {
|
||||
executionArgs: ExecutionArgs;
|
||||
}): EndHandler | void {
|
||||
@@ -64,7 +64,7 @@ export class LoggerExtension implements GraphQLExtension<CommonContext> {
|
||||
|
||||
public willSendResponse(response: {
|
||||
graphqlResponse: GraphQLResponse;
|
||||
context: CommonContext;
|
||||
context: GraphContext;
|
||||
}): void {
|
||||
if (response.graphqlResponse.errors) {
|
||||
response.graphqlResponse.errors.forEach(err =>
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import CommonContext from "coral-server/graph/common/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { Metrics } from "coral-server/services/metrics";
|
||||
import { ExecutionArgs } from "graphql";
|
||||
import { EndHandler, GraphQLExtension } from "graphql-extensions";
|
||||
@@ -6,7 +6,7 @@ import now from "performance-now";
|
||||
|
||||
import { getOperationMetadata } from "./helpers";
|
||||
|
||||
export class MetricsExtension implements GraphQLExtension<CommonContext> {
|
||||
export class MetricsExtension implements GraphQLExtension<GraphContext> {
|
||||
constructor(private metrics: Metrics) {}
|
||||
|
||||
public executionDidStart(o: {
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import DataLoader from "dataloader";
|
||||
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import { GQLDiscoveredOIDCConfiguration } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { GQLDiscoveredOIDCConfiguration } from "coral-server/graph/schema/__generated__/types";
|
||||
import { discoverOIDCConfiguration } from "coral-server/services/tenant";
|
||||
|
||||
export default (ctx: TenantContext) => ({
|
||||
export default (ctx: GraphContext) => ({
|
||||
discoverOIDCConfiguration: new DataLoader<
|
||||
string,
|
||||
GQLDiscoveredOIDCConfiguration | null
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { defaultTo } from "lodash";
|
||||
|
||||
import Context from "coral-server/graph/tenant/context";
|
||||
import Context from "coral-server/graph/context";
|
||||
import {
|
||||
CommentActionConnectionInput,
|
||||
retrieveCommentActionConnection,
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import { defaultTo } from "lodash";
|
||||
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import {
|
||||
CommentToStatusHistoryArgs,
|
||||
UserToCommentModerationActionHistoryArgs,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import { retrieveCommentModerationActionConnection } from "coral-server/models/action/moderation/comment";
|
||||
|
||||
export default (ctx: TenantContext) => ({
|
||||
export default (ctx: GraphContext) => ({
|
||||
forModerator: (
|
||||
{ first, after }: UserToCommentModerationActionHistoryArgs,
|
||||
moderatorID: string
|
||||
+2
-2
@@ -2,7 +2,7 @@ import DataLoader from "dataloader";
|
||||
import { defaultTo, isNil, omitBy } from "lodash";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
import Context from "coral-server/graph/tenant/context";
|
||||
import Context from "coral-server/graph/context";
|
||||
import {
|
||||
CommentToParentsArgs,
|
||||
CommentToRepliesArgs,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
UserToAllCommentsArgs,
|
||||
UserToCommentsArgs,
|
||||
UserToRejectedCommentsArgs,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import { retrieveManyUserActionPresence } from "coral-server/models/action/comment";
|
||||
import {
|
||||
Comment,
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
import DataLoader from "dataloader";
|
||||
import { defaultTo } from "lodash";
|
||||
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import {
|
||||
GQLSTORY_STATUS,
|
||||
QueryToStoriesArgs,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import { Connection } from "coral-server/models/helpers";
|
||||
import {
|
||||
retrieveManyStories,
|
||||
@@ -54,7 +54,7 @@ const queryFilter = (query?: string): StoryConnectionInput["filter"] => {
|
||||
*
|
||||
* @param ctx graph context to use to prime the loaders.
|
||||
*/
|
||||
const primeStoriesFromConnection = (ctx: TenantContext) => (
|
||||
const primeStoriesFromConnection = (ctx: GraphContext) => (
|
||||
connection: Readonly<Connection<Readonly<Story>>>
|
||||
) => {
|
||||
if (!ctx.disableCaching) {
|
||||
@@ -67,7 +67,7 @@ const primeStoriesFromConnection = (ctx: TenantContext) => (
|
||||
return connection;
|
||||
};
|
||||
|
||||
export default (ctx: TenantContext) => ({
|
||||
export default (ctx: GraphContext) => ({
|
||||
findOrCreate: new DataLoader(
|
||||
createManyBatchLoadFn((input: FindOrCreateStory) =>
|
||||
findOrCreate(ctx.mongo, ctx.tenant, input, ctx.scraperQueue, ctx.now)
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
import DataLoader from "dataloader";
|
||||
import { defaultTo } from "lodash";
|
||||
|
||||
import Context from "coral-server/graph/tenant/context";
|
||||
import Context from "coral-server/graph/context";
|
||||
import {
|
||||
GQLUSER_ROLE,
|
||||
GQLUSER_STATUS,
|
||||
QueryToUsersArgs,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import { Connection } from "coral-server/models/helpers";
|
||||
import {
|
||||
retrieveManyUsers,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import Context from "coral-server/graph/tenant/context";
|
||||
import Context from "coral-server/graph/context";
|
||||
|
||||
import Auth from "./Auth";
|
||||
import CommentActions from "./CommentActions";
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { approveComment, rejectComment } from "coral-server/stacks";
|
||||
|
||||
import {
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
GQLRejectCommentInput,
|
||||
} from "../schema/__generated__/types";
|
||||
|
||||
export const Actions = (ctx: TenantContext) => ({
|
||||
export const Actions = (ctx: GraphContext) => ({
|
||||
approveComment: (input: GQLApproveCommentInput) =>
|
||||
approveComment(
|
||||
ctx.mongo,
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import { ERROR_CODES } from "coral-common/errors";
|
||||
import { ADDITIONAL_DETAILS_MAX_LENGTH } from "coral-common/helpers/validate";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/common/errors";
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/errors";
|
||||
import { addTag, removeTag } from "coral-server/services/comments";
|
||||
import {
|
||||
createDontAgree,
|
||||
@@ -30,11 +30,11 @@ import {
|
||||
GQLRemoveCommentReactionInput,
|
||||
GQLTAG,
|
||||
GQLUnfeatureCommentInput,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { validateMaximumLength, WithoutMutationID } from "./util";
|
||||
|
||||
export const Comments = (ctx: TenantContext) => ({
|
||||
export const Comments = (ctx: GraphContext) => ({
|
||||
create: ({
|
||||
clientMutationId,
|
||||
nudge = false,
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { Tenant } from "coral-server/models/tenant";
|
||||
import {
|
||||
disableFeatureFlag,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import {
|
||||
GQLFEATURE_FLAG,
|
||||
GQLUpdateSettingsInput,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const Settings = ({
|
||||
mongo,
|
||||
@@ -19,7 +19,7 @@ export const Settings = ({
|
||||
tenant,
|
||||
config,
|
||||
now,
|
||||
}: TenantContext) => ({
|
||||
}: GraphContext) => ({
|
||||
update: (input: GQLUpdateSettingsInput): Promise<Tenant | null> =>
|
||||
update(mongo, redis, tenantCache, config, tenant, input.settings),
|
||||
regenerateSSOKey: (): Promise<Tenant | null> =>
|
||||
+14
-13
@@ -1,18 +1,8 @@
|
||||
import { isNull, omitBy } from "lodash";
|
||||
|
||||
import { ERROR_CODES } from "coral-common/errors";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/common/errors";
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import {
|
||||
GQLCloseStoryInput,
|
||||
GQLCreateStoryInput,
|
||||
GQLMergeStoriesInput,
|
||||
GQLOpenStoryInput,
|
||||
GQLRemoveStoryInput,
|
||||
GQLScrapeStoryInput,
|
||||
GQLUpdateStoryInput,
|
||||
GQLUpdateStorySettingsInput,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/errors";
|
||||
import { Story } from "coral-server/models/story";
|
||||
import {
|
||||
close,
|
||||
@@ -25,7 +15,18 @@ import {
|
||||
} from "coral-server/services/stories";
|
||||
import { scrape } from "coral-server/services/stories/scraper";
|
||||
|
||||
export const Stories = (ctx: TenantContext) => ({
|
||||
import {
|
||||
GQLCloseStoryInput,
|
||||
GQLCreateStoryInput,
|
||||
GQLMergeStoriesInput,
|
||||
GQLOpenStoryInput,
|
||||
GQLRemoveStoryInput,
|
||||
GQLScrapeStoryInput,
|
||||
GQLUpdateStoryInput,
|
||||
GQLUpdateStorySettingsInput,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const Stories = (ctx: GraphContext) => ({
|
||||
create: async (input: GQLCreateStoryInput): Promise<Readonly<Story> | null> =>
|
||||
mapFieldsetToErrorCodes(
|
||||
create(
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
import { ERROR_CODES } from "coral-common/errors";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/common/errors";
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import { mapFieldsetToErrorCodes } from "coral-server/graph/errors";
|
||||
import { User } from "coral-server/models/user";
|
||||
import {
|
||||
addModeratorNote,
|
||||
@@ -65,9 +65,10 @@ import {
|
||||
GQLUpdateUserRoleInput,
|
||||
GQLUpdateUserUsernameInput,
|
||||
} from "../schema/__generated__/types";
|
||||
|
||||
import { WithoutMutationID } from "./util";
|
||||
|
||||
export const Users = (ctx: TenantContext) => ({
|
||||
export const Users = (ctx: GraphContext) => ({
|
||||
invite: async ({ role, emails }: GQLInviteUsersInput) =>
|
||||
mapFieldsetToErrorCodes(
|
||||
invite(
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
|
||||
import { Actions } from "./Actions";
|
||||
import { Comments } from "./Comments";
|
||||
@@ -6,7 +6,7 @@ import { Settings } from "./Settings";
|
||||
import { Stories } from "./Stories";
|
||||
import { Users } from "./Users";
|
||||
|
||||
export default (ctx: TenantContext) => ({
|
||||
export default (ctx: GraphContext) => ({
|
||||
Actions: Actions(ctx),
|
||||
Comments: Comments(ctx),
|
||||
Settings: Settings(ctx),
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { parse } from "graphql";
|
||||
import path from "path";
|
||||
|
||||
import { version } from "coral-common/version";
|
||||
import { getOperationMetadata } from "coral-server/graph/common/extensions/helpers";
|
||||
import { getOperationMetadata } from "coral-server/graph/extensions/helpers";
|
||||
import logger from "coral-server/logger";
|
||||
import { PersistedQuery } from "coral-server/models/queries";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLApproveCommentPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLApproveCommentPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLAuthIntegrations,
|
||||
GQLAuthIntegrationsTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
const disabled = { enabled: false };
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLBanStatusTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLBanStatusTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export type BanStatusInput = user.ConsolidatedBanStatus & {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLBanStatusHistoryTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLBanStatusHistoryTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export const BanStatusHistory: Required<
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCloseCommentingTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCloseCommentingTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as settings from "coral-server/models/settings";
|
||||
import { translate } from "coral-server/services/i18n";
|
||||
|
||||
+9
-8
@@ -2,11 +2,7 @@ import { GraphQLResolveInfo } from "graphql";
|
||||
import { defaultTo } from "lodash";
|
||||
|
||||
import { StoryNotFoundError } from "coral-server/errors";
|
||||
import { getRequestedFields } from "coral-server/graph/tenant/resolvers/util";
|
||||
import {
|
||||
GQLComment,
|
||||
GQLCommentTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { getRequestedFields } from "coral-server/graph/resolvers/util";
|
||||
import {
|
||||
ACTION_TYPE,
|
||||
decodeActionCounts,
|
||||
@@ -21,10 +17,15 @@ import { createConnection } from "coral-server/models/helpers";
|
||||
import { getURLWithCommentID } from "coral-server/models/story";
|
||||
import { getCommentEditableUntilDate } from "coral-server/services/comments";
|
||||
|
||||
import TenantContext from "../context";
|
||||
import {
|
||||
GQLComment,
|
||||
GQLCommentTypeResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import GraphContext from "../context";
|
||||
|
||||
export const maybeLoadOnlyID = (
|
||||
ctx: TenantContext,
|
||||
ctx: GraphContext,
|
||||
info: GraphQLResolveInfo,
|
||||
id: string
|
||||
) => {
|
||||
@@ -78,7 +79,7 @@ export const Comment: GQLCommentTypeResolver<comment.Comment> = {
|
||||
|
||||
const children = await ctx.loaders.Comments.comment.loadMany(childIDs);
|
||||
return children.reduce(
|
||||
(sum, c) => (c && hasPublishedStatus(c) ? sum + 1 : sum),
|
||||
(sum: any, c: any) => (c && hasPublishedStatus(c) ? sum + 1 : sum),
|
||||
0
|
||||
);
|
||||
},
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentCountsTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentCountsTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import {
|
||||
calculateTotalPublishedCommentCount,
|
||||
Story,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentCreatedPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentCreatedPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentCreatedInput } from "./Subscription/commentCreated";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentEnteredModerationQueuePayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentEnteredModerationQueuePayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentEnteredModerationQueueInput } from "./Subscription/commentEnteredModerationQueue";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentLeftModerationQueuePayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentLeftModerationQueuePayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentLeftModerationQueueInput } from "./Subscription/commentLeftModerationQueue";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentReleasedPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentReleasedPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentReleasedInput } from "./Subscription/commentReleased";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentReplyCreatedPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentReplyCreatedPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentReplyCreatedInput } from "./Subscription/commentReplyCreated";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentRevisionTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentRevisionTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import { decodeActionCounts } from "coral-server/models/action/comment";
|
||||
import { Comment, Revision } from "coral-server/models/comment";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLCommentStatusUpdatedPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLCommentStatusUpdatedPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { maybeLoadOnlyID } from "./Comment";
|
||||
import { CommentStatusUpdatedInput } from "./Subscription/commentStatusUpdated";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLDisableCommentingTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLDisableCommentingTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as settings from "coral-server/models/settings";
|
||||
import { translate } from "coral-server/services/i18n";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLFacebookAuthIntegration,
|
||||
GQLFacebookAuthIntegrationTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { reconstructTenantURLResolver } from "./util";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLFeatureCommentPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLFeatureCommentPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLCOMMENT_FLAG_REASON,
|
||||
GQLFlagTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import * as actions from "coral-server/models/action/comment";
|
||||
|
||||
export const Flag: GQLFlagTypeResolver<actions.CommentAction> = {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLGoogleAuthIntegration,
|
||||
GQLGoogleAuthIntegrationTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { reconstructTenantURLResolver } from "./util";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLInviteTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLInviteTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as invite from "coral-server/models/invite";
|
||||
|
||||
export const Invite: GQLInviteTypeResolver<invite.Invite> = {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { isUndefined } from "lodash";
|
||||
|
||||
import { GQLLiveConfigurationTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLLiveConfigurationTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as settings from "coral-server/models/settings";
|
||||
|
||||
export type LiveConfigurationInput = settings.LiveConfiguration;
|
||||
+9
-8
@@ -1,9 +1,3 @@
|
||||
import {
|
||||
ApproveCommentPayloadToModerationQueuesResolver,
|
||||
GQLModerationQueuesTypeResolver,
|
||||
QueryToModerationQueuesResolver,
|
||||
RejectCommentPayloadToModerationQueuesResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { CommentConnectionInput } from "coral-server/models/comment";
|
||||
import { FilterQuery } from "coral-server/models/helpers";
|
||||
import {
|
||||
@@ -16,7 +10,14 @@ import {
|
||||
UNMODERATED_STATUSES,
|
||||
} from "coral-server/services/comments/moderation/counts";
|
||||
|
||||
import TenantContext from "../context";
|
||||
import {
|
||||
ApproveCommentPayloadToModerationQueuesResolver,
|
||||
GQLModerationQueuesTypeResolver,
|
||||
QueryToModerationQueuesResolver,
|
||||
RejectCommentPayloadToModerationQueuesResolver,
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import GraphContext from "../context";
|
||||
import { ModerationQueueInput } from "./ModerationQueue";
|
||||
|
||||
interface ModerationQueuesInput {
|
||||
@@ -70,7 +71,7 @@ export const storyModerationInputResolver = (
|
||||
export const sharedModerationInputResolver = async (
|
||||
source: any,
|
||||
args: any,
|
||||
ctx: TenantContext
|
||||
ctx: GraphContext
|
||||
): Promise<ModerationQueuesInput> => ({
|
||||
// We don't need to filter the connection, as this is tenant wide (tenant
|
||||
// filtering is completed at the model layer).
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLModeratorNoteTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLModeratorNoteTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export const ModeratorNote: Required<
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLMutationTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLMutationTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
// TODO: (wyattjoh) add rate limiting to these edges
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLOIDCAuthIntegration,
|
||||
GQLOIDCAuthIntegrationTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { reconstructTenantURLResolver } from "./util";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLPremodStatusTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLPremodStatusTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export type PremodStatusInput = user.ConsolidatedPremodStatus & {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLPremodStatusHistoryTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLPremodStatusHistoryTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export const PremodStatusHistory: Required<
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLProfileTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLProfileTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
const resolveType: GQLProfileTypeResolver<user.Profile> = profile => {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLQueryTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLQueryTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLRecentCommentHistoryTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLRecentCommentHistoryTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export interface RecentCommentHistoryInput {
|
||||
userID: string;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLRejectCommentPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLRejectCommentPayloadTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import * as settings from "coral-server/models/settings";
|
||||
|
||||
import { GQLSSOAuthIntegrationTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLSSOAuthIntegrationTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
function getActiveSSOKey(keys: settings.SSOKey[]) {
|
||||
// Any key that has been rotated cannot be the active key.
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { Tenant } from "coral-server/models/tenant";
|
||||
import {
|
||||
GQLFEATURE_FLAG,
|
||||
GQLSettingsTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
const filterValidFeatureFlags = () => {
|
||||
// Compute the valid flags based on this enum.
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLSlackConfiguration,
|
||||
GQLSlackConfigurationTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
export const SlackConfiguration: GQLSlackConfigurationTypeResolver<
|
||||
GQLSlackConfiguration
|
||||
+3
-3
@@ -4,15 +4,15 @@ import {
|
||||
GQLSTORY_STATUS,
|
||||
GQLStoryTypeResolver,
|
||||
GQLTAG,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import { decodeActionCounts } from "coral-server/models/action/comment";
|
||||
import * as story from "coral-server/models/story";
|
||||
|
||||
import TenantContext from "../context";
|
||||
import GraphContext from "../context";
|
||||
import { CommentCountsInput } from "./CommentCounts";
|
||||
import { storyModerationInputResolver } from "./ModerationQueues";
|
||||
|
||||
const isStoryClosed = (s: story.Story, ctx: TenantContext) => {
|
||||
const isStoryClosed = (s: story.Story, ctx: GraphContext) => {
|
||||
const closedAt = story.getStoryClosedAt(ctx.tenant, s) || null;
|
||||
return !!closedAt && new Date() >= closedAt;
|
||||
};
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SubscriptionToCommentCreatedResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { SubscriptionToCommentCreatedResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLMODERATION_QUEUE,
|
||||
SubscriptionToCommentEnteredModerationQueueResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SubscriptionToCommentFeaturedResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { SubscriptionToCommentFeaturedResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLMODERATION_QUEUE,
|
||||
SubscriptionToCommentLeftModerationQueueResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SubscriptionToCommentReleasedResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { SubscriptionToCommentReleasedResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SubscriptionToCommentReplyCreatedResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { SubscriptionToCommentReplyCreatedResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
GQLCOMMENT_STATUS,
|
||||
SubscriptionToCommentStatusUpdatedResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { createIterator } from "./helpers";
|
||||
import {
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
import { GraphQLResolveInfo } from "graphql";
|
||||
import { withFilter } from "graphql-subscriptions";
|
||||
|
||||
import TenantContext from "../../context";
|
||||
import GraphContext from "../../context";
|
||||
import { SUBSCRIPTION_CHANNELS, SubscriptionPayload } from "./types";
|
||||
|
||||
type FilterFn<TParent, TArgs, TContext> = (
|
||||
@@ -14,7 +14,7 @@ type FilterFn<TParent, TArgs, TContext> = (
|
||||
type Resolver<TParent, TArgs, TResult> = (
|
||||
source: TParent,
|
||||
args: TArgs,
|
||||
ctx: TenantContext,
|
||||
ctx: GraphContext,
|
||||
info: GraphQLResolveInfo
|
||||
) => TResult;
|
||||
|
||||
@@ -56,7 +56,7 @@ export function createSubscriptionChannelName(
|
||||
export function defaultFilterFn<TParent extends SubscriptionPayload, TArgs>(
|
||||
source: TParent,
|
||||
args: TArgs,
|
||||
ctx: TenantContext
|
||||
ctx: GraphContext
|
||||
): boolean {
|
||||
if (source.clientID && ctx.clientID && source.clientID === ctx.clientID) {
|
||||
return false;
|
||||
@@ -71,8 +71,8 @@ export function defaultFilterFn<TParent extends SubscriptionPayload, TArgs>(
|
||||
* prevent double responses.
|
||||
*/
|
||||
export function createFilterFn<TParent, TArgs>(
|
||||
filter?: FilterFn<TParent, TArgs, TenantContext>
|
||||
): FilterFn<TParent, TArgs, TenantContext> {
|
||||
filter?: FilterFn<TParent, TArgs, GraphContext>
|
||||
): FilterFn<TParent, TArgs, GraphContext> {
|
||||
return filter
|
||||
? // Combine the filters, preferring the defaultFilterFn first.
|
||||
(source, args, ctx, info) => {
|
||||
@@ -86,7 +86,7 @@ export function createFilterFn<TParent, TArgs>(
|
||||
}
|
||||
|
||||
export interface CreateIteratorInput<TParent, TArgs, TResult> {
|
||||
filter?: FilterFn<TParent, TArgs, TenantContext>;
|
||||
filter?: FilterFn<TParent, TArgs, GraphContext>;
|
||||
}
|
||||
|
||||
export function createIterator<
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLSubscriptionTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLSubscriptionTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
|
||||
import { commentCreated } from "./commentCreated";
|
||||
import { commentEnteredModerationQueue } from "./commentEnteredModerationQueue";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLSuspensionStatusTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLSuspensionStatusTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export type SuspensionStatusInput = user.ConsolidatedSuspensionStatus & {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLSuspensionStatusHistoryTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLSuspensionStatusHistoryTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
|
||||
export const SuspensionStatusHistory: Required<
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { GQLTagTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { GQLTagTypeResolver } from "coral-server/graph/schema/__generated__/types";
|
||||
import { CommentTag } from "coral-server/models/comment/tag";
|
||||
|
||||
export const Tag: GQLTagTypeResolver<CommentTag> = {
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import { GraphQLResolveInfo } from "graphql";
|
||||
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import GraphContext from "coral-server/graph/context";
|
||||
import {
|
||||
GQLUser,
|
||||
GQLUserTypeResolver,
|
||||
} from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
} from "coral-server/graph/schema/__generated__/types";
|
||||
import * as user from "coral-server/models/user";
|
||||
import { roleIsStaff } from "coral-server/models/user/helpers";
|
||||
|
||||
@@ -13,7 +13,7 @@ import { UserStatusInput } from "./UserStatus";
|
||||
import { getRequestedFields } from "./util";
|
||||
|
||||
const maybeLoadOnlyIgnoredUserID = (
|
||||
ctx: TenantContext,
|
||||
ctx: GraphContext,
|
||||
info: GraphQLResolveInfo,
|
||||
users?: user.IgnoredUser[]
|
||||
) => {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user