protected override SchemaExtensionNode RewriteSchemaExtension( SchemaExtensionNode node, string context) { var directives = new List <DirectiveNode>(); foreach (DirectiveNode directive in node.Directives) { switch (directive.Name.Value) { case DirectiveNames.RemoveType: case DirectiveNames.RenameField: case DirectiveNames.RenameType: case DirectiveNames.RemoveRootTypes: _directives.Add(directive); break; default: directives.Add(directive); break; } } return(node.WithDirectives(directives)); }
protected override void VisitSchemaExtension( SchemaExtensionNode node, TypeDefinitionItem context) { VisitMany( node.Directives, context, VisitDirective); VisitMany( node.OperationTypes, context, VisitOperationTypeDefinition); }
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 RemoteSchemaDefinition Build( IDescriptorContext context, ISchema schema) { var extensionDocuments = new List <DocumentNode>(context.GetTypeExtensions(_key)); if (_schemaDirectives.Count > 0) { var schemaExtension = new SchemaExtensionNode( null, _schemaDirectives, Array.Empty <OperationTypeDefinitionNode>()); extensionDocuments.Add(new DocumentNode(new[] { schemaExtension })); } return(new RemoteSchemaDefinition( _name.HasValue ? _name : schema.Name, schema.ToDocument(), extensionDocuments)); }
protected virtual ISyntaxVisitorAction Enter( SchemaExtensionNode node, ISyntaxVisitorContext context) => DefaultAction;
protected virtual ISyntaxVisitorAction Leave( SchemaExtensionNode node, TContext context) => DefaultAction;
private void VisitSchemaExtension(SchemaExtensionNode node, ISyntaxWriter writer) { writer.Write(Keywords.Extend); writer.WriteSpace(); VisitSchemaDefinitionBase(node, writer); }