Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function executeField(
field: FieldNode,
rootValue: any,
execContext: ExecContext,
): Promise {
const { variableValues: variables, contextValue, resolver } = execContext;
const fieldName = field.name.value;
const args = argumentsObjectFromField(field, variables);
const info: ExecInfo = {
isLeaf: !field.selectionSet,
resultKey: resultKeyNameFromField(field),
directives: getDirectiveInfoFromField(field, variables),
field,
};
const result = await resolver(fieldName, rootValue, args, contextValue, info);
// Handle all scalar types here
if (!field.selectionSet) {
return result;
}
// From here down, the field has a selection set, which means it's trying to
function executeField(
field: FieldNode,
rootValue: any,
execContext: ExecContext,
): ExecResult {
const { variableValues: variables, contextValue } = execContext;
const fieldName = field.name.value;
const args = argumentsObjectFromField(field, variables);
const info: ExecInfo = {
resultKey: resultKeyNameFromField(field),
directives: getDirectiveInfoFromField(field, variables),
};
const readStoreResult = readStoreResolver(
fieldName,
rootValue,
args,
contextValue,
info,
);
// Handle all scalar types here
if (!field.selectionSet) {
function executeField(
field: FieldNode,
rootValue: any,
execContext: ExecContext,
): any {
const { variableValues: variables, contextValue, resolver } = execContext;
const fieldName = field.name.value;
const args = argumentsObjectFromField(field, variables);
const info: ExecInfo = {
isLeaf: !field.selectionSet,
resultKey: resultKeyNameFromField(field),
directives: getDirectiveInfoFromField(field, variables),
};
const result = resolver(fieldName, rootValue, args, contextValue, info);
// Handle all scalar types here
if (!field.selectionSet) {
return result;
}
// From here down, the field has a selection set, which means it's trying to
// query a GraphQLObjectType
async function executeField(field, rootValue, execContext) {
const { variables, contextValue, resolver } = execContext
const fieldName = field.name.value
const args = argumentsObjectFromField(field, variables)
const info = {
isLeaf: !field.selectionSet,
resultKey: resultKeyNameFromField(field),
directives: getDirectivesFromField(field, variables)
}
const result = await resolver(fieldName, rootValue, args, contextValue, info)
// Handle all scalar types here
if (!field.selectionSet) {
return result
}
// From here down, the field has a selection set, which means it's trying to
// query a GraphQLObjectType
}
// keep track of info about the original query
queryInfo[trackerId] = {
includedFields: [], // TODO: implement - do we need it, or does apollo auto filter?
name: functionName,
path: [contractAlias, functionAlias],
type: QUERY_TYPE,
};
// convert contract queries to calls
return [...queries, createCallQuery({
abiCoder,
abiItem,
address,
args: argumentsObjectFromField(selection, {}) || {},
trackerId,
})];
}, [] as FieldNode[]);
return [...acc, ...contractCallQueries];
// if we've specifically identified that we only want to run forced
// resolvers (that is, resolvers for fields marked with
// `@client(always: true)`), then we'll skip running non-forced resolvers.
if (
!execContext.onlyRunForcedResolvers ||
this.shouldForceResolvers(field)
) {
const resolverType =
rootValue.__typename || execContext.defaultOperationType;
const resolverMap = this.resolvers && this.resolvers[resolverType];
if (resolverMap) {
const resolve = resolverMap[aliasUsed ? fieldName : aliasedFieldName];
if (resolve) {
resultPromise = Promise.resolve(resolve(
rootValue,
argumentsObjectFromField(field, variables),
execContext.context,
{ field, fragmentMap: execContext.fragmentMap },
));
}
}
}
return resultPromise.then((result = defaultResult) => {
// If an @export directive is associated with the current field, store
// the `as` export variable name and current result for later use.
if (field.directives) {
field.directives.forEach(directive => {
if (directive.name.value === 'export' && directive.arguments) {
directive.arguments.forEach(arg => {
if (arg.name.value === 'as' && arg.value.kind === 'StringValue') {
execContext.exportedVariables[arg.value.value] = result;
function executeField(
field: FieldNode,
rootValue: any,
execContext: ExecContext,
): any {
const { variableValues: variables, contextValue, resolver } = execContext;
const fieldName = field.name.value;
const args = argumentsObjectFromField(field, variables);
const info: ExecInfo = {
isLeaf: !field.selectionSet,
resultKey: resultKeyNameFromField(field),
directives: getDirectiveInfoFromField(field, variables),
};
const result = resolver(fieldName, rootValue, args, contextValue, info);
// Handle all scalar types here
if (!field.selectionSet) {
return result;
}
// From here down, the field has a selection set, which means it's trying to
// query a GraphQLObjectType
private executeField(
object: StoreObject,
typename: string | void,
field: FieldNode,
execContext: ExecContext,
): ExecResult {
const { variableValues: variables, contextValue } = execContext;
const fieldName = field.name.value;
const args = argumentsObjectFromField(field, variables);
const info: ExecInfo = {
resultKey: resultKeyNameFromField(field),
directives: getDirectiveInfoFromField(field, variables),
};
const readStoreResult = readStoreResolver(
object,
typename,
fieldName,
args,
contextValue,
info,
);
if (Array.isArray(readStoreResult.result)) {