Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build(obj, args, context, info, isAuthenticated, match = null) {
// Use PostGraphile parser to get nested query object
const query = graphql_parse_resolve_info_1.parseResolveInfo(info);
const costTree = {};
// The first query is always a aggregation (array of objects) => Just like SQL you'll always get rows
const { sql, counter, values, authRequired } = this.jsonAgg(0, query, [], isAuthenticated, match, costTree);
const maxDepth = this.calculateMaxDepth(costTree[query.name]);
const potentialHighCost = maxDepth >= this.minQueryDepthToCheckCostLimit;
return { sql: `SELECT ${sql};`, values, query, authRequired, potentialHighCost, costTree, maxDepth };
}
}
build(obj, args, context, info) {
// Use PostGraphile parser to get nested query object
const query = graphql_parse_resolve_info_1.parseResolveInfo(info);
// Get mutation information from generated Schema-data
const mutation = this.resolverMeta.mutation[query.name];
// Switch mutation type
switch (mutation.type) {
case "CREATE":
return this.resolveCreateMutation(query, mutation);
case "UPDATE":
return this.resolveUpdateMutation(query, mutation);
case "DELETE":
return this.resolveDeleteMutation(query, mutation);
default:
throw new Error(`Mutation-Type does not exist: ${mutation.type}`);
}
}
}
export function parseResolveInfo(info: GraphQLResolveInfo): IParsedResolveInfo {
return graphQlParseResolveInfo(info);
}
constructor(
public originalResolveInfoRoot: GraphQLResolveInfo,
public rootSource: TSrc,
parsedResolveInfo?: ResolveTree,
public parentSource?: TParentVisitor,
) {
this.parsedResolveInfo =
parsedResolveInfo ||
//TODO: Remove any after version incompatibility with typings is resolved
(parseResolveInfo(originalResolveInfoRoot as any) as any);
}
constructor(
public originalResolveInfoRoot: GraphQLResolveInfo,
public rootSource: TSrc,
parsedResolveInfo?: ResolveTree,
public parentSource?: TParentVisitor,
) {
this.parsedResolveInfo =
parsedResolveInfo ||
//TODO: Remove any after version incompatibility with typings is resolved
(parseResolveInfo(originalResolveInfoRoot as any) as any);
}
function getSafeAliasFromResolveInfo(
resolveInfo: import("graphql").GraphQLResolveInfo
) {
const alias = rawGetAliasFromResolveInfo(resolveInfo);
return getSafeAliasFromAlias(alias);
}