private async Task <ExpandoObject> TryGetObject(FieldScope scope, GraphQLObjectType input, GraphQLFieldSelection selection, IEnumerable <object> path) { try { return(await scope.GetObject(this.context.FieldCollector.CollectFields(input, selection.SelectionSet))); } catch (GraphQLResolveException) { return(null); } }
private object CompleteObjectType( GraphQLObjectType input, GraphQLFieldSelection selection, IList <GraphQLArgument> arguments, object parentObject) { var scope = new FieldScope( this.typeTranslator, this.valueResolver, this.fieldCollector, input, parentObject); scope.arguments = arguments.ToList(); return(scope.GetObject(this.fieldCollector.CollectFields(input, selection.SelectionSet))); }
private dynamic ComposeResultForType(GraphQLObjectType type, GraphQLSelectionSet selectionSet) { var variableResolver = new VariableResolver(this.variables, this.graphQLSchema.TypeTranslator, this.operation.VariableDefinitions); var valueResolver = new ValueResolver(variableResolver, this.graphQLSchema.TypeTranslator); var fieldCollector = new FieldCollector(this.fragments, valueResolver); var scope = new FieldScope( this.graphQLSchema.TypeTranslator, valueResolver, fieldCollector, type, null); return(scope.GetObject(fieldCollector.CollectFields(type, selectionSet))); }
public async Task <ExpandoObject> ComposeResultForQuery( GraphQLComplexType type, GraphQLOperationDefinition operationDefinition, object parent = null) { var context = this.CreateExecutionContext(operationDefinition); var scope = new FieldScope(context, type, parent); var fields = context.FieldCollector.CollectFields(type, operationDefinition.SelectionSet); var resultObject = await scope.GetObject(fields); await this.AppendIntrospectionInfo(scope, fields, resultObject); var returnObject = new ExpandoObject(); var returnObjectDictionary = (IDictionary <string, object>)returnObject; returnObjectDictionary.Add("data", resultObject); if (scope.Errors.Any()) { returnObjectDictionary.Add("errors", scope.Errors); } return(returnObject); }