예제 #1
0
        /// <summary>
        /// Updates the field resolver used by this graph field.
        /// </summary>
        /// <param name="newResolver">The new resolver this field should use.</param>
        /// <param name="mode">The new resolution mode used by the runtime to invoke the resolver.</param>
        public void UpdateResolver(IGraphFieldResolver newResolver, FieldResolutionMode mode)
        {
            this.Resolver = newResolver;
            this.Mode     = mode;

            var unrwrappedType = GraphValidation.EliminateWrappersFromCoreType(this.Resolver?.ObjectType);

            this.IsLeaf = this.Resolver?.ObjectType != null && GraphQLProviders.ScalarProvider.IsLeaf(unrwrappedType);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyGraphField" /> class.
 /// </summary>
 /// <param name="fieldName">Name of the field in the public graph.</param>
 /// <param name="typeExpression">The type expression declaring what type of data this field returns.</param>
 /// <param name="route">The route to this field in the graph.</param>
 /// <param name="propertyType">The property metadata.</param>
 /// <param name="propertyDeclaredName">The name of the property as it was declared on the <see cref="Type"/> (its internal name).</param>
 /// <param name="mode">The mode in which the runtime will process this field.</param>
 /// <param name="resolver">The resolver to be invoked to produce data when this field is called.</param>
 /// <param name="securityPolicies">The security policies that apply to this field.</param>
 public PropertyGraphField(
     string fieldName,
     GraphTypeExpression typeExpression,
     GraphFieldPath route,
     Type propertyType,
     string propertyDeclaredName,
     FieldResolutionMode mode     = FieldResolutionMode.PerSourceItem,
     IGraphFieldResolver resolver = null,
     IEnumerable <FieldSecurityGroup> securityPolicies = null)
     : base(fieldName, typeExpression, route, mode, resolver, securityPolicies)
 {
     this.ObjectType   = propertyType;
     this.InternalName = propertyDeclaredName;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodGraphField" /> class.
 /// </summary>
 /// <param name="fieldName">Name of the field in the graph.</param>
 /// <param name="typeExpression">The meta data describing the type of data this field returns.</param>
 /// <param name="route">The formal route to this field in the object graph.</param>
 /// <param name="mode">The mode in which the runtime will process this field.</param>
 /// <param name="resolver">The resolver to be invoked to produce data when this field is called.</param>
 /// <param name="securityPolicies">The security policies that apply to this field.</param>
 public MethodGraphField(
     string fieldName,
     GraphTypeExpression typeExpression,
     GraphFieldPath route,
     FieldResolutionMode mode     = FieldResolutionMode.PerSourceItem,
     IGraphFieldResolver resolver = null,
     IEnumerable <FieldSecurityGroup> securityPolicies = null)
 {
     this.Name           = fieldName;
     this.TypeExpression = Validation.ThrowIfNullOrReturn(typeExpression, nameof(typeExpression));
     this.Route          = Validation.ThrowIfNullOrReturn(route, nameof(route));
     this.Arguments      = new GraphFieldArgumentCollection();
     this.SecurityGroups = securityPolicies ?? Enumerable.Empty <FieldSecurityGroup>();
     this.UpdateResolver(resolver, mode);
 }
예제 #4
0
 /// <summary>
 /// Updates the field resolver used by this graph field.
 /// </summary>
 /// <param name="newResolver">The new resolver this field should use.</param>
 /// <param name="mode">The new resolution mode used by the runtime to invoke the resolver.</param>
 public void UpdateResolver(IGraphFieldResolver newResolver, FieldResolutionMode mode)
 {
     throw new InvalidOperationException($"The resolver for '{typeof(VirtualGraphField).FriendlyName()}' cannot be altered.");
 }