Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResolveFieldContext"/> class.
 /// </summary>
 /// <param name="fieldName">Name of the field.</param>
 /// <param name="fieldAst">The field ast.</param>
 /// <param name="fieldDefinition">The field definition.</param>
 /// <param name="returnType">Type of the return.</param>
 /// <param name="parentType">Type of the parent.</param>
 /// <param name="arguments">The arguments.</param>
 /// <param name="rootValue">The root value.</param>
 /// <param name="source">The source.</param>
 /// <param name="schema">The schema.</param>
 /// <param name="operation">The operation.</param>
 /// <param name="fragments">The fragments.</param>
 /// <param name="variables">The variables.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <param name="userContext">The user context.</param>
 public ResolveFieldContext(
     string fieldName,
     Field fieldAst,
     FieldType fieldDefinition,
     GraphType returnType,
     ObjectGraphType parentType,
     IReadOnlyDictionary<string, object> arguments,
     object rootValue,
     object source,
     ISchema schema,
     Operation operation,
     IEnumerable<IFragment> fragments,
     IEnumerable<Variable> variables,
     CancellationToken cancellationToken,
     object userContext)
 {
     FieldName = fieldName;
     FieldAst = fieldAst;
     FieldDefinition = fieldDefinition;
     ReturnType = returnType;
     ParentType = parentType;
     Arguments = arguments;
     RootValue = rootValue;
     Source = source;
     Schema = schema;
     Operation = operation;
     Fragments = fragments;
     Variables = variables;
     CancellationToken = cancellationToken;
     UserContext = userContext;
 }
Exemplo n.º 2
0
        public FieldType GetFieldDefinition(ISchema schema, ObjectGraphType parentType, Field field)
        {
            if (field.Name == SchemaIntrospection.SchemaMeta.Name && schema.Query == parentType)
            {
                return SchemaIntrospection.SchemaMeta;
            }
            if (field.Name == SchemaIntrospection.TypeMeta.Name && schema.Query == parentType)
            {
                return SchemaIntrospection.TypeMeta;
            }
            if (field.Name == SchemaIntrospection.TypeNameMeta.Name)
            {
                return SchemaIntrospection.TypeNameMeta;
            }

            return parentType.Fields.FirstOrDefault(f => f.Name == field.Name);
        }