Exemplo n.º 1
0
        private void OnBeforeCompleteName(
            ITypeCompletionContext completionContext,
            SortInputTypeDefinition definition)
        {
            ISortConvention convention = GetConvention(
                completionContext.DescriptorContext,
                definition.Scope);

            var descriptor = SortInputTypeDescriptor.New(
                completionContext.DescriptorContext,
                definition.EntityType,
                definition.Scope);

            SchemaTypeReference typeReference = TypeReference.Create(
                completionContext.Type,
                definition.Scope);

            convention.ApplyConfigurations(typeReference, descriptor);

            DataTypeExtensionHelper.MergeSortInputTypeDefinitions(
                completionContext,
                descriptor.CreateDefinition(),
                definition);

            if (definition is { Name : {} } &&
Exemplo n.º 2
0
        private void ConfigureSortInputType(
            ITypeDiscoveryContext discoveryContext,
            SortInputTypeDefinition definition)
        {
            ISortConvention convention = GetConvention(
                discoveryContext.DescriptorContext,
                definition.Scope);

            var descriptor = SortInputTypeDescriptor.From(
                discoveryContext.DescriptorContext,
                definition,
                definition.Scope);

            SchemaTypeReference typeReference = TypeReference.Create(
                discoveryContext.Type,
                definition.Scope);

            convention.ApplyConfigurations(typeReference, descriptor);

            foreach (InputFieldDefinition field in definition.Fields)
            {
                if (field is SortFieldDefinition sortFieldDefinition)
                {
                    if (discoveryContext.TryPredictTypeKind(
                            sortFieldDefinition.Type,
                            out TypeKind kind) &&
                        kind != TypeKind.Enum)
                    {
                        field.Type = field.Type.With(scope: discoveryContext.Scope);
                    }

                    if (convention.TryGetFieldHandler(
                            discoveryContext,
                            definition,
                            sortFieldDefinition,
                            out ISortFieldHandler? handler))
                    {
                        sortFieldDefinition.Handler = handler;
                    }
                    else
                    {
                        throw ThrowHelper.SortInterceptor_NoFieldHandlerFoundForField(
                                  definition,
                                  sortFieldDefinition);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ConfigureSortEnumType(
            ITypeDiscoveryContext discoveryContext,
            SortEnumTypeDefinition definition)
        {
            ISortConvention convention = GetConvention(
                discoveryContext.DescriptorContext,
                discoveryContext.Scope);

            ISortEnumTypeDescriptor descriptor = SortEnumTypeDescriptor.From(
                discoveryContext.DescriptorContext,
                definition);

            SchemaTypeReference typeReference = TypeReference.Create(
                discoveryContext.Type,
                discoveryContext.Scope);

            convention.ApplyConfigurations(typeReference, descriptor);

            foreach (var enumValue in definition.Values)
            {
                if (enumValue is SortEnumValueDefinition sortEnumValueDefinition)
                {
                    if (convention.TryGetOperationHandler(
                            discoveryContext,
                            definition,
                            sortEnumValueDefinition,
                            out ISortOperationHandler? handler))
                    {
                        sortEnumValueDefinition.Handler = handler;
                    }
                    else
                    {
                        throw ThrowHelper.SortInterceptor_NoOperationHandlerFoundForValue(
                                  definition,
                                  sortEnumValueDefinition);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void OnBeforeRegisteringDependencies(
            ITypeDiscoveryContext discoveryContext,
            SortEnumTypeDefinition definition)
        {
            ISortConvention convention = GetConvention(
                discoveryContext.DescriptorContext,
                definition.Scope);

            var descriptor = SortEnumTypeDescriptor.New(
                discoveryContext.DescriptorContext,
                definition.EntityType,
                definition.Scope);

            SchemaTypeReference typeReference = TypeReference.Create(
                discoveryContext.Type,
                definition.Scope);

            convention.ApplyConfigurations(typeReference, descriptor);

            SortEnumTypeDefinition extensionDefinition = descriptor.CreateDefinition();

            discoveryContext.RegisterDependencies(extensionDefinition);
        }