public void ApplyBinding(
            ISchemaContext schemaContext,
            ResolverBindingInfo resolverBindingInfo)
        {
            if (resolverBindingInfo is ResolverCollectionBindingInfo b)
            {
                if (b.ObjectType == null)
                {
                    b.ObjectType = typeof(object);
                }

                List <IFieldResolverDescriptor> descriptors =
                    CollectPossibleDescriptors(schemaContext.Types, b);

                IEnumerable <IFieldResolverDescriptor>
                mostSpecificFieldResolvers =
                    GetMostSpecificFieldResolvers(
                        schemaContext.Types, descriptors);

                foreach (IFieldResolverDescriptor descriptor in
                         mostSpecificFieldResolvers)
                {
                    schemaContext.Resolvers.RegisterResolver(descriptor);
                }
            }
            else
            {
                throw new NotSupportedException(
                          "The binding type is not supported by this handler.");
            }
        }
Exemple #2
0
 public void ApplyBinding(
     ISchemaContext schemaContext,
     ResolverBindingInfo resolverBindingInfo)
 {
     if (resolverBindingInfo is ResolverDelegateBindingInfo b)
     {
         if (b.AsyncFieldResolver == null)
         {
             schemaContext.Resolvers.RegisterResolver(
                 new DelegateResolverBinding(
                     b.ObjectTypeName, b.FieldName, b.FieldResolver));
         }
         else
         {
             FieldResolverDelegate fieldResolverDelegate =
                 (ctx, ct) => b.AsyncFieldResolver(ctx, ct);
             schemaContext.Resolvers.RegisterResolver(
                 new DelegateResolverBinding(
                     b.ObjectTypeName, b.FieldName, fieldResolverDelegate));
         }
     }
     else
     {
         throw new NotSupportedException(
                   "The binding type is not supported by this handler.");
     }
 }
 public void ApplyBinding(
     ISchemaContext schemaContext,
     ResolverBindingInfo resolverBindingInfo)
 {
     if (resolverBindingInfo is ResolverDelegateBindingInfo b)
     {
         schemaContext.Resolvers.RegisterResolver(
             b.CreateFieldResolver());
     }
     else
     {
         throw new NotSupportedException(
                   "The binding type is not supported by this handler.");
     }
 }