예제 #1
0
 public IPublishSchemaDefinitionDescriptor SetName(NameString name)
 {
     _name = name;
     return(this);
 }
 public ICompletedDependencyDescriptor DependsOn(
     NameString typeName) =>
 DependsOn(typeName, false);
예제 #3
0
 protected IntTypeBase(NameString name)
     : this(name, int.MinValue, int.MaxValue)
 {
 }
예제 #4
0
 public static IRequestExecutorBuilder AddGraphQLServer(
     this IRequestExecutorBuilder builder,
     NameString schemaName = default) =>
 builder.Services.AddGraphQLServer(schemaName);
예제 #5
0
 public static InvalidOperationException RequestExecutorResolver_SchemaNameDoesNotMatch(
     NameString configurationSchemaName, NameString schemaName) =>
 new InvalidOperationException(
     "The schema name must allign with the schema name expected by the configuration.");
예제 #6
0
 protected DateTimeTypeBase(NameString name)
     : base(name)
 {
 }
        public IObjectFieldDescriptor Field(NameString name)
        {
            ObjectFieldDescriptor fieldDescriptor =
                Fields.FirstOrDefault(t => t.Definition.Name.Equals(name));

            if (fieldDescriptor is { })
 public new IObjectFieldDescriptor Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
예제 #9
0
 /// <inheritdoc />
 public new IFilterInputTypeDescriptor <T> Ignore(NameString name)
 {
     base.Ignore(name);
     return(this);
 }
예제 #10
0
 /// <inheritdoc/>
 public new IArrayFilterFieldDescriptor <TArray> Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
 public static ObjectFieldDescriptor New(
     IDescriptorContext context,
     NameString fieldName) =>
 new ObjectFieldDescriptor(context, fieldName);
예제 #12
0
 public bool ContainsType(NameString typeName) =>
 _typeMap.ContainsKey(typeName.EnsureNotEmpty(nameof(typeName)));
예제 #13
0
        public override FieldMiddleware CreateExecutor <TEntityType>(NameString argumentName)
        {
            return(next => context => ExecuteAsync(next, context));

            async ValueTask ExecuteAsync(
                FieldDelegate next,
                IMiddlewareContext context)
            {
                // first we let the pipeline run and produce a result.
                await next(context).ConfigureAwait(false);

                // next we get the filter argument. If the filter argument is already on the context
                // we use this. This enabled overriding the context with LocalContextData
                IInputField argument = context.Field.Arguments[argumentName];
                IValueNode  filter   = context.LocalContextData.ContainsKey(ContextValueNodeKey) &&
                                       context.LocalContextData[ContextValueNodeKey] is IValueNode node
                        ? node
                        : context.ArgumentLiteral <IValueNode>(argumentName);

                // if no filter is defined we can stop here and yield back control.
                if (filter.IsNull() ||
                    (context.LocalContextData.TryGetValue(
                         SkipFilteringKey,
                         out object?skipObject) &&
                     skipObject is bool skip &&
                     skip))
                {
                    return;
                }

                IQueryable <TEntityType>?source = null;

                if (context.Result is IQueryable <TEntityType> q)
                {
                    source = q;
                }
                else if (context.Result is IEnumerable <TEntityType> e)
                {
                    source = e.AsQueryable();
                }

                if (source != null &&
                    argument.Type is IFilterInputType filterInput &&
                    context.Field.ContextData.TryGetValue(
                        ContextVisitFilterArgumentKey,
                        out object?executorObj) &&
                    executorObj is VisitFilterArgument executor)
                {
                    QueryableFilterContext visitorContext = executor(
                        filter,
                        filterInput,
                        source is EnumerableQuery);

                    // compile expression tree
                    if (visitorContext.TryCreateLambda(
                            out Expression <Func <TEntityType, bool> >?where))
                    {
                        context.Result = source.Where(where);
                    }
                    else
                    {
                        if (visitorContext.Errors.Count > 0)
                        {
                            context.Result = Array.Empty <TEntityType>();
                            foreach (IError error in visitorContext.Errors)
                            {
                                context.ReportError(error.WithPath(context.Path));
                            }
                        }
                    }
                }
            }
        }
예제 #14
0
 /// <inheritdoc/>
 public new IBooleanFilterOperationDescriptor Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
 public void ConfigureField(NameString argumentName, IObjectFieldDescriptor descriptor)
 {
     throw new NotImplementedException();
 }
예제 #16
0
 /// <inheritdoc />
 public new IFilterInputTypeDescriptor <T> Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
예제 #17
0
 public NameDirectiveReference(NameString name)
 {
     Name = name.EnsureNotEmpty(nameof(name));
 }
 /// <inheritdoc />
 public ISortConventionDescriptor ArgumentName(NameString argumentName)
 {
     Definition.ArgumentName = argumentName;
     return(this);
 }
예제 #19
0
 public IObjectTypeDescriptor Name(NameString value)
 {
     Definition.Name = value.EnsureNotEmpty(nameof(value));
     return(this);
 }
예제 #20
0
 public static bool IsBuiltIn(NameString typeName)
 {
     return(typeName.HasValue &&
            _directiveNames.Contains(typeName.Value));
 }
예제 #21
0
        /// <inheritdoc />
        public virtual NameString GetTypeName(Type runtimeType)
        {
            if (runtimeType is null)
            {
                throw new ArgumentNullException(nameof(runtimeType));
            }

            if (typeof(IEnumOperationFilterInputType).IsAssignableFrom(runtimeType) &&
                runtimeType.GenericTypeArguments.Length == 1 &&
                runtimeType.GetGenericTypeDefinition() == typeof(EnumOperationFilterInputType <>))
            {
                NameString genericName =
                    _namingConventions.GetTypeName(runtimeType.GenericTypeArguments[0]);

                return(genericName.Value + "OperationFilterInput");
            }

            if (typeof(IComparableOperationFilterInputType).IsAssignableFrom(runtimeType) &&
                runtimeType.GenericTypeArguments.Length == 1 &&
                runtimeType.GetGenericTypeDefinition() ==
                typeof(ComparableOperationFilterInputType <>))
            {
                NameString genericName =
                    _namingConventions.GetTypeName(runtimeType.GenericTypeArguments[0]);

                return($"Comparable{genericName.Value}OperationFilterInput");
            }

            if (typeof(IListFilterInputType).IsAssignableFrom(runtimeType) &&
                runtimeType.GenericTypeArguments.Length == 1 &&
                runtimeType.GetGenericTypeDefinition() == typeof(ListFilterInputType <>))
            {
                Type       genericType = runtimeType.GenericTypeArguments[0];
                NameString genericName;
                if (typeof(FilterInputType).IsAssignableFrom(genericType))
                {
                    genericName = GetTypeName(genericType);
                }
                else
                {
                    genericName = _namingConventions.GetTypeName(genericType);
                }

                return("List" + genericName.Value);
            }

            string name = _namingConventions.GetTypeName(runtimeType);

            var isInputObjectType = typeof(FilterInputType).IsAssignableFrom(runtimeType);
            var isEndingInput     = name.EndsWith(_inputPostFix, StringComparison.Ordinal);
            var isEndingInputType = name.EndsWith(_inputTypePostFix, StringComparison.Ordinal);

            if (isInputObjectType && isEndingInputType)
            {
                return(name.Substring(0, name.Length - 4));
            }

            if (isInputObjectType && !isEndingInput && !isEndingInputType)
            {
                return(name + _inputPostFix);
            }

            if (!isInputObjectType && !isEndingInput)
            {
                return(name + _inputPostFix);
            }

            return(name);
        }
예제 #22
0
 public FloatType(NameString name)
     : this(name, double.MinValue, double.MaxValue)
 {
 }
 /// <inheritdoc/>
 public new IObjectFilterOperationDescriptor <TObject> Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
예제 #24
0
 public FloatType(NameString name, double min, double max)
     : base(name, min, max)
 {
 }
예제 #25
0
 public new IDirectiveTypeDescriptor <T> Name(NameString value)
 {
     base.Name(value);
     return(this);
 }
예제 #26
0
 public FloatType(NameString name, string description, double min, double max)
     : base(name, min, max)
 {
     Description = description;
 }
 public IFilterInputTypeDescriptor <T> Name(NameString value)
 {
     Definition.Name = value.EnsureNotEmpty(nameof(value));
     return(this);
 }
 public FieldMiddleware CreateExecutor <TEntityType>(NameString argumentName)
 {
     throw new NotImplementedException();
 }
예제 #29
0
 protected IntTypeBase(NameString name, int min, int max)
     : base(name)
 {
     _min = min;
     _max = max;
 }
예제 #30
0
 public bool Contains(NameString key) => _lookup.Contains(key);