private static DescriptorContext CreateContext( SchemaBuilder builder, LazySchema lazySchema) { IServiceProvider services = builder._services ?? new EmptyServiceProvider(); var schemaInterceptors = new List <ISchemaInterceptor>(); var typeInterceptors = new List <ITypeInitializationInterceptor>(); InitializeInterceptors(services, builder._schemaInterceptors, schemaInterceptors); InitializeInterceptors(services, builder._typeInterceptors, typeInterceptors); var schemaInterceptor = new AggregateSchemaInterceptor(schemaInterceptors); var typeInterceptor = new AggregateTypeInterceptor(typeInterceptors); DescriptorContext context = DescriptorContext.Create( builder._options, services, builder._conventions, builder._contextData, lazySchema, schemaInterceptor, typeInterceptor); schemaInterceptor.OnBeforeCreate(context, builder); return(context); }
public Schema Create() { IServiceProvider services = _services ?? new EmptyServiceProvider(); IBindingLookup bindingLookup = _bindingCompiler.Compile(DescriptorContext.Create(services)); var types = new List <ITypeReference>(_types); if (_documents.Count > 0) { types.AddRange(ParseDocuments(services, bindingLookup)); } var lazy = new LazySchema(); TypeInitializer initializer = InitializeTypes(services, bindingLookup, types, () => lazy.Schema); SchemaDefinition definition = CreateSchemaDefinition(initializer); if (definition.QueryType == null && _options.StrictValidation) { // TODO : Resources throw new SchemaException( SchemaErrorBuilder.New() .SetMessage("No QUERY TYPE") .Build()); } var schema = new Schema(definition); lazy.Schema = schema; return(schema); }
private static Schema CompleteSchema( SchemaBuilder builder, DescriptorContext context, LazySchema lazySchema, TypeRegistry typeRegistry) { SchemaTypesDefinition definition = CreateSchemaDefinition(builder, context, typeRegistry); if (definition.QueryType is null && builder._options.StrictValidation) { throw new SchemaException( SchemaErrorBuilder.New() .SetMessage(TypeResources.SchemaBuilder_NoQueryType) .Build()); } Schema schema = typeRegistry.Types .Select(t => t.Type).OfType <Schema>().First(); schema.CompleteSchema(definition); lazySchema.Schema = schema; context.SchemaInterceptor.OnAfterCreate(context, schema); return(schema); }
public Schema Create() { IServiceProvider services = _services ?? new EmptyServiceProvider(); DescriptorContext descriptorContext = DescriptorContext.Create(_options, services); IBindingLookup bindingLookup = _bindingCompiler.Compile(descriptorContext); var types = new List <ITypeReference>(_types); if (_documents.Count > 0) { types.AddRange(ParseDocuments(services, bindingLookup)); } if (_schema == null) { types.Add(new SchemaTypeReference(new Schema())); } else { types.Add(_schema); } var lazy = new LazySchema(); TypeInitializer initializer = InitializeTypes( services, descriptorContext, bindingLookup, types, () => lazy.Schema); SchemaTypesDefinition definition = CreateSchemaDefinition(initializer); if (definition.QueryType == null && _options.StrictValidation) { throw new SchemaException( SchemaErrorBuilder.New() .SetMessage(TypeResources.SchemaBuilder_NoQueryType) .Build()); } Schema schema = initializer.Types.Values .Select(t => t.Type) .OfType <Schema>() .First(); schema.CompleteSchema(definition); lazy.Schema = schema; return(schema); }
public Schema Create() { IServiceProvider services = _services ?? new EmptyServiceProvider(); var descriptorContext = DescriptorContext.Create( _options, services, CreateConventions(services), _contextData); foreach (Action <IDescriptorContext> action in _onBeforeCreate) { action(descriptorContext); } IBindingLookup bindingLookup = _bindingCompiler.Compile(descriptorContext); IReadOnlyCollection <ITypeReference> types = GetTypeReferences(services, bindingLookup); var lazy = new LazySchema(); TypeInitializer initializer = CreateTypeInitializer( services, descriptorContext, bindingLookup, types); DiscoveredTypes discoveredTypes = initializer.Initialize(() => lazy.Schema, _options); SchemaTypesDefinition definition = CreateSchemaDefinition(initializer, discoveredTypes); if (definition.QueryType == null && _options.StrictValidation) { throw new SchemaException( SchemaErrorBuilder.New() .SetMessage(TypeResources.SchemaBuilder_NoQueryType) .Build()); } Schema schema = discoveredTypes.Types .Select(t => t.Type) .OfType <Schema>() .First(); schema.CompleteSchema(definition); lazy.Schema = schema; TypeInspector.Default.Clear(); return(schema); }
private static TypeRegistry InitializeTypes( SchemaBuilder builder, IDescriptorContext context, IReadOnlyList <ITypeReference> types, LazySchema lazySchema) { var typeRegistry = new TypeRegistry(context.TypeInterceptor); TypeInitializer initializer = CreateTypeInitializer(builder, context, types, typeRegistry); initializer.Initialize(() => lazySchema.Schema, builder._options); return(typeRegistry); }
public static Schema Create(SchemaBuilder builder) { var lazySchema = new LazySchema(); DescriptorContext context = CreateContext(builder, lazySchema); IBindingLookup bindingLookup = builder._bindingCompiler.Compile(context); IReadOnlyList <ITypeReference> typeReferences = CreateTypeReferences(builder, context, bindingLookup); TypeRegistry typeRegistry = InitializeTypes(builder, context, bindingLookup, typeReferences, lazySchema); return(CompleteSchema(builder, context, lazySchema, typeRegistry)); }
public static Schema Create( SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context) { try { var schemaInterceptors = new List <ISchemaInterceptor>(); var typeInterceptors = new List <ITypeInitializationInterceptor>(); if (context.Options.StrictRuntimeTypeValidation && !builder._typeInterceptors.Contains(typeof(TypeValidationTypeInterceptor))) { builder._typeInterceptors.Add(typeof(TypeValidationTypeInterceptor)); } InitializeInterceptors( context.Services, builder._schemaInterceptors, schemaInterceptors); InitializeInterceptors( context.Services, builder._typeInterceptors, typeInterceptors); ((AggregateSchemaInterceptor)context.SchemaInterceptor) .SetInterceptors(schemaInterceptors); ((AggregateTypeInterceptor)context.TypeInterceptor) .SetInterceptors(typeInterceptors); context.SchemaInterceptor.OnBeforeCreate(context, builder); IReadOnlyList <ITypeReference> typeReferences = CreateTypeReferences(builder, context); TypeRegistry typeRegistry = InitializeTypes(builder, context, typeReferences, lazySchema); return(CompleteSchema(builder, context, lazySchema, typeRegistry)); } catch (Exception ex) { context.SchemaInterceptor.OnError(context, ex); throw; } }
public Schema Create() { IServiceProvider services = _services ?? new EmptyServiceProvider(); var descriptorContext = DescriptorContext.Create( _options, services, CreateConventions(services)); IBindingLookup bindingLookup = _bindingCompiler.Compile(descriptorContext); IReadOnlyCollection <ITypeReference> types = GetTypeReferences(services, bindingLookup); var lazy = new LazySchema(); TypeInitializer initializer = InitializeTypes( services, descriptorContext, bindingLookup, types, () => lazy.Schema); SchemaTypesDefinition definition = CreateSchemaDefinition(initializer); if (definition.QueryType == null && _options.StrictValidation) { throw new SchemaException( SchemaErrorBuilder.New() .SetMessage(TypeResources.SchemaBuilder_NoQueryType) .Build()); } Schema schema = initializer.Types.Values .Select(t => t.Type) .OfType <Schema>() .First(); schema.CompleteSchema(definition); lazy.Schema = schema; return(schema); }
private static DescriptorContext CreateContext( SchemaBuilder builder, LazySchema lazySchema) { DescriptorContext context = DescriptorContext.Create( builder._options, builder._services ?? new EmptyServiceProvider(), builder._conventions, builder._contextData, lazySchema); foreach (Action <IDescriptorContext> action in builder._onBeforeCreate) { action(context); } return(context); }
public static DescriptorContext CreateContext( SchemaBuilder builder, LazySchema lazySchema) { IServiceProvider services = builder._services ?? new EmptyServiceProvider(); var schemaInterceptor = new AggregateSchemaInterceptor(); var typeInterceptor = new AggregateTypeInterceptor(); DescriptorContext context = DescriptorContext.Create( builder._options, services, builder._conventions, builder._contextData, lazySchema, schemaInterceptor, typeInterceptor); return(context); }
public static Schema Create(SchemaBuilder builder) { var lazySchema = new LazySchema(); DescriptorContext context = CreateContext(builder, lazySchema); try { IBindingLookup bindingLookup = builder._bindingCompiler.Compile(context); IReadOnlyList <ITypeReference> typeReferences = CreateTypeReferences(builder, context, bindingLookup); TypeRegistry typeRegistry = InitializeTypes(builder, context, bindingLookup, typeReferences, lazySchema); return(CompleteSchema(builder, context, lazySchema, typeRegistry)); } catch (Exception ex) { context.SchemaInterceptor.OnError(context, ex); throw; } }