protected override void VisitInterfaceTypeDefinition( InterfaceTypeDefinitionNode node, object context) { _types.Add(SchemaTypeReference.Create( _interfaceTypeFactory.Create(_bindingLookup, node))); }
private void VisitInterfaceTypeDefinition( InterfaceTypeDefinitionNode node, ISyntaxWriter writer) { WriteDescription(node.Description, writer); VisitInterfaceTypeDefinitionBase(node, writer); }
public void CreateInterfaceType() { // arrange InterfaceTypeDefinitionNode typeDefinition = CreateTypeDefinition <InterfaceTypeDefinitionNode>( "interface Simple { a: String b: [String] }"); // act var factory = new InterfaceTypeFactory(); InterfaceType type = factory.Create(typeDefinition); CompleteType(type); // assert Assert.Equal("Simple", type.Name); Assert.Equal(2, type.Fields.Count); Assert.True(type.Fields.ContainsField("a")); Assert.False(type.Fields["a"].Type.IsNonNullType()); Assert.False(type.Fields["a"].Type.IsListType()); Assert.True(type.Fields["a"].Type.IsScalarType()); Assert.Equal("String", type.Fields["a"].Type.TypeName()); Assert.True(type.Fields.ContainsField("b")); Assert.False(type.Fields["b"].Type.IsNonNullType()); Assert.True(type.Fields["b"].Type.IsListType()); Assert.False(type.Fields["b"].Type.IsScalarType()); Assert.Equal("String", type.Fields["b"].Type.TypeName()); }
RewriteInterfaceTypeDefinition( InterfaceTypeDefinitionNode node, MergeContext context) { InterfaceTypeDefinitionNode current = node; if (context.Extensions.TryGetValue( current.Name.Value, out ITypeExtensionNode extension)) { if (extension is InterfaceTypeExtensionNode ite) { current = AddFields(current, ite); current = AddDirectives(current, ite, d => current.WithDirectives(d), context); } else { throw new SchemaMergeException( current, extension, string.Format( CultureInfo.InvariantCulture, StitchingResources .AddSchemaExtensionRewriter_TypeMismatch, node.Name.Value, node.Kind, extension.Kind)); } } return(base.RewriteInterfaceTypeDefinition(current, context)); }
public static InterfaceTypeDefinitionNode Rename( this InterfaceTypeDefinitionNode interfaceTypeDefinition, NameString newName, IEnumerable <NameString> schemaNames) { return(AddSource(interfaceTypeDefinition, newName, schemaNames, (n, d) => interfaceTypeDefinition .WithName(n).WithDirectives(d))); }
public static InterfaceTypeDefinitionNode Rename( this InterfaceTypeDefinitionNode interfaceTypeDefinition, NameString newName, params NameString[] schemaNames) { return(Rename( interfaceTypeDefinition, newName, (IEnumerable <NameString>)schemaNames)); }
RewriteInterfaceTypeDefinition( InterfaceTypeDefinitionNode node, Context context) { if (IsRelevant(node, context)) { return(base.RewriteInterfaceTypeDefinition(node, context)); } return(node); }
private static InterfaceTypeDefinitionNode AddFields( InterfaceTypeDefinitionNode typeDefinition, InterfaceTypeExtensionNode typeExtension) { IReadOnlyList <FieldDefinitionNode> fields = AddFields(typeDefinition.Fields, typeExtension.Fields); return(fields == typeDefinition.Fields ? typeDefinition : typeDefinition.WithFields(fields)); }
protected override void VisitInterfaceTypeDefinition( InterfaceTypeDefinitionNode node, TypeDefinitionItem context) { var item = new TypeDefinitionItem { Name = node.Name.ToString(), Type = TypeDefinitionType.Interface }; VisitName(node.Name, context); VisitIfNotNull(node.Description, context, VisitStringValue); VisitMany(node.Directives, context, VisitDirective); VisitMany(node.Fields, item, VisitFieldDefinition); this.VisitedItems.Add(item); }
protected override void MergeTypes( ISchemaMergeContext context, IReadOnlyList <InterfaceTypeInfo> types, NameString newTypeName) { List <InterfaceTypeDefinitionNode> definitions = types .Select(t => t.Definition) .ToList(); InterfaceTypeDefinitionNode definition = definitions[0].Rename( newTypeName, types.Select(t => t.Schema.Name)); context.AddType(definition); }
private static void RenameInterfaceField( InterfaceTypeDefinitionNode interfaceType, RenameFieldsContext renameContext) { foreach (FieldDefinitionNode fieldDefinition in interfaceType.Fields) { NameString originalName = fieldDefinition.GetOriginalName(renameContext.SchemaName); if (!originalName.Equals(fieldDefinition.Name.Value)) { RenameInterfaceField( interfaceType, renameContext, originalName, fieldDefinition.Name.Value); } } }
protected sealed override ISyntaxVisitorAction Enter( ISyntaxNode node, ISyntaxVisitorContext context) { return(node switch { DocumentNode n => Enter(n, context), OperationDefinitionNode n => Enter(n, context), VariableDefinitionNode n => Enter(n, context), VariableNode n => Enter(n, context), SelectionSetNode n => Enter(n, context), FieldNode n => Enter(n, context), ArgumentNode n => Enter(n, context), FragmentSpreadNode n => Enter(n, context), InlineFragmentNode n => Enter(n, context), FragmentDefinitionNode n => Enter(n, context), DirectiveNode n => Enter(n, context), NamedTypeNode n => Enter(n, context), ListTypeNode n => Enter(n, context), NonNullTypeNode n => Enter(n, context), ListValueNode n => Enter(n, context), ObjectValueNode n => Enter(n, context), ObjectFieldNode n => Enter(n, context), IValueNode n => Enter(n, context), SchemaDefinitionNode n => Enter(n, context), OperationTypeDefinitionNode n => Enter(n, context), ScalarTypeDefinitionNode n => Enter(n, context), ObjectTypeDefinitionNode n => Enter(n, context), FieldDefinitionNode n => Enter(n, context), InputValueDefinitionNode n => Enter(n, context), InterfaceTypeDefinitionNode n => Enter(n, context), UnionTypeDefinitionNode n => Enter(n, context), EnumTypeDefinitionNode n => Enter(n, context), EnumValueDefinitionNode n => Enter(n, context), InputObjectTypeDefinitionNode n => Enter(n, context), DirectiveDefinitionNode n => Enter(n, context), SchemaExtensionNode n => Enter(n, context), ScalarTypeExtensionNode n => Enter(n, context), ObjectTypeExtensionNode n => Enter(n, context), InterfaceTypeExtensionNode n => Enter(n, context), UnionTypeExtensionNode n => Enter(n, context), EnumTypeExtensionNode n => Enter(n, context), InputObjectTypeExtensionNode n => Enter(n, context), _ => throw new NotSupportedException() });
public void InterfaceFieldDeprecationReason() { // arrange InterfaceTypeDefinitionNode typeDefinition = CreateTypeDefinition <InterfaceTypeDefinitionNode>(@" interface Simple { a: String @deprecated(reason: ""reason123"") }"); // act var factory = new InterfaceTypeFactory(); InterfaceType type = factory.Create(typeDefinition); CompleteType(type); // assert Assert.True(type.Fields["a"].IsDeprecated); Assert.Equal("reason123", type.Fields["a"].DeprecationReason); }
private static void RenameInterfaceField( InterfaceTypeDefinitionNode interfaceType, RenameFieldsContext renameContext, NameString originalFieldName, NameString newFieldName) { List <ObjectTypeDefinitionNode> objectTypes = renameContext.Types.Values .OfType <ObjectTypeDefinitionNode>() .Where(t => t.Interfaces.Select(i => i.Name.Value) .Any(n => string.Equals(n, interfaceType.Name.Value, StringComparison.Ordinal))) .ToList(); AddNewFieldName(interfaceType, renameContext, originalFieldName, newFieldName); foreach (ObjectTypeDefinitionNode objectType in objectTypes) { AddNewFieldName(objectType, renameContext, originalFieldName, newFieldName); } }
public InterfaceType(InterfaceTypeDefinitionNode definition) { this.definition = definition; this.Name = definition.Name?.Value; }
public new IInterfaceTypeDescriptor <T> SyntaxNode( InterfaceTypeDefinitionNode interfaceTypeDefinition) { base.SyntaxNode(interfaceTypeDefinition); return(this); }
protected virtual ISyntaxVisitorAction Enter( InterfaceTypeDefinitionNode node, ISyntaxVisitorContext context) => DefaultAction;
protected override void VisitInterfaceTypeDefinition( InterfaceTypeDefinitionNode node) { _typeRegistry.RegisterType(_interfaceTypeFactory.Create(node)); }
IInterfaceTypeDescriptor IInterfaceTypeDescriptor.SyntaxNode( InterfaceTypeDefinitionNode syntaxNode) { SyntaxNode = syntaxNode; return(this); }
protected void SyntaxNode(InterfaceTypeDefinitionNode syntaxNode) { InterfaceDescription.SyntaxNode = syntaxNode; }
public IInterfaceTypeDescriptor SyntaxNode( InterfaceTypeDefinitionNode interfaceTypeDefinitionNode) { Definition.SyntaxNode = interfaceTypeDefinitionNode; return(this); }
protected virtual void VisitInterfaceTypeDefinition(InterfaceTypeDefinitionNode node) { }