public UnionType Create( IBindingLookup bindingLookup, UnionTypeDefinitionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new UnionType(d => { d.SyntaxNode(node) .Name(node.Name.Value) .Description(node.Description?.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate(t => t.RuntimeType = bindingInfo.SourceType); } foreach (NamedTypeNode namedType in node.Types) { d.Type(namedType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } })); }
public UnionTypeExtension Create( IBindingLookup bindingLookup, IReadOnlySchemaOptions schemaOptions, UnionTypeExtensionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new UnionTypeExtension(d => { d.Name(node.Name.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.RuntimeType = bindingInfo.SourceType); } foreach (NamedTypeNode namedType in node.Types) { d.Type(namedType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } })); }
public InterfaceType Create( IBindingLookup bindingLookup, InterfaceTypeDefinitionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new InterfaceType(d => { d.SyntaxNode(node) .Name(node.Name.Value) .Description(node.Description?.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.RuntimeType = bindingInfo.SourceType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } DeclareInterfaces(d, node.Interfaces); DeclareFields(d, node.Fields); })); }
private IReadOnlyCollection <ITypeReference> GetTypeReferences( IServiceProvider services, IBindingLookup bindingLookup) { 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); } return(types); }
public EnumTypeExtension Create( IBindingLookup bindingLookup, IReadOnlySchemaOptions schemaOptions, EnumTypeExtensionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new EnumTypeExtension(d => { d.Name(node.Name.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.RuntimeType = bindingInfo.SourceType); } foreach (DirectiveNode directive in node.Directives) { if (!directive.IsDeprecationReason()) { d.Directive(directive); } } DeclareValues(d, node.Values); })); }
public DirectiveType Create( IBindingLookup bindingLookup, DirectiveDefinitionNode node) { if (bindingLookup == null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new DirectiveType(c => { c.Name(node.Name.Value); c.Description(node.Description?.Value); c.SyntaxNode(node); if (bindingInfo.SourceType != null) { c.Extend().OnBeforeCreate( t => t.RuntimeType = bindingInfo.SourceType); } if (node.IsRepeatable) { c.Repeatable(); } DeclareArguments(c, node); DeclareLocations(c, node); })); }
public InterfaceTypeExtension Create( IBindingLookup bindingLookup, IReadOnlySchemaOptions schemaOptions, InterfaceTypeExtensionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new InterfaceTypeExtension(d => { d.Name(node.Name.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.RuntimeType = bindingInfo.SourceType); } DeclareInterfaces(d, node.Interfaces); foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } DeclareFields(schemaOptions, d, node.Fields); })); }
public EnumType Create( IBindingLookup bindingLookup, EnumTypeDefinitionNode node) { if (bindingLookup == null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new EnumType(d => { d.SyntaxNode(node) .Name(node.Name.Value) .Description(node.Description?.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.ClrType = bindingInfo.SourceType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } DeclareValues(d, node.Values); })); }
public InputObjectType Create( IBindingLookup bindingLookup, IReadOnlySchemaOptions schemaOptions, InputObjectTypeDefinitionNode node) { if (bindingLookup is null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node is null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new InputObjectType(d => { d.SyntaxNode(schemaOptions.PreserveSyntaxNodes ? node : null) .Name(node.Name.Value) .Description(node.Description?.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate(t => t.RuntimeType = bindingInfo.SourceType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } DeclareFields(bindingInfo, schemaOptions, d, node); })); }
public ObjectTypeExtension Create( IBindingLookup bindingLookup, ObjectTypeExtensionNode node) { if (bindingLookup == null) { throw new ArgumentNullException(nameof(bindingLookup)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } ITypeBindingInfo bindingInfo = bindingLookup.GetBindingInfo(node.Name.Value); return(new ObjectTypeExtension(d => { d.Name(node.Name.Value); if (bindingInfo.SourceType != null) { d.Extend().OnBeforeCreate( t => t.ClrType = bindingInfo.SourceType); } foreach (DirectiveNode directive in node.Directives) { d.Directive(directive); } DeclareInterfaces(d, node.Interfaces); DeclareFields(bindingInfo, d, node.Fields); })); }
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; } }
public SchemaSyntaxVisitor(IBindingLookup bindingLookup) { _bindingLookup = bindingLookup ?? throw new ArgumentNullException(nameof(bindingLookup)); }