private static void DeclareFields( ObjectTypeDefinition parent, IReadOnlyCollection <FieldDefinitionNode> fields, bool preserveSyntaxNodes) { foreach (FieldDefinitionNode field in fields) { var fieldDefinition = new ObjectFieldDefinition( field.Name.Value, field.Description?.Value, TypeReference.Create(field.Type)); fieldDefinition.BindTo = field.GetBindingValue(); if (preserveSyntaxNodes) { fieldDefinition.SyntaxNode = field; } SdlToTypeSystemHelper.AddDirectives(fieldDefinition, field); if (field.DeprecationReason() is { Length: > 0 } reason) { fieldDefinition.DeprecationReason = reason; } DeclareFieldArguments(fieldDefinition, field, preserveSyntaxNodes); parent.Fields.Add(fieldDefinition); } }
public ObjectType Create(IDescriptorContext context, ObjectTypeDefinitionNode node) { var preserveSyntaxNodes = context.Options.PreserveSyntaxNodes; var typeDefinition = new ObjectTypeDefinition( node.Name.Value, node.Description?.Value); typeDefinition.BindTo = node.GetBindingValue(); if (preserveSyntaxNodes) { typeDefinition.SyntaxNode = node; } foreach (NamedTypeNode typeNode in node.Interfaces) { typeDefinition.Interfaces.Add(TypeReference.Create(typeNode)); } SdlToTypeSystemHelper.AddDirectives(typeDefinition, node); DeclareFields(typeDefinition, node.Fields, preserveSyntaxNodes); return(ObjectType.CreateUnsafe(typeDefinition)); }
private static void DeclareValues( EnumTypeDefinition parent, IReadOnlyCollection <EnumValueDefinitionNode> values, bool preserveSyntaxNodes) { foreach (EnumValueDefinitionNode value in values) { var valueDefinition = new EnumValueDefinition( value.Name.Value, value.Description?.Value, value.Name.Value); valueDefinition.BindTo = value.GetBindingValue(); if (preserveSyntaxNodes) { valueDefinition.SyntaxNode = value; } SdlToTypeSystemHelper.AddDirectives(valueDefinition, value); if (value.DeprecationReason() is { Length: > 0 } reason) { valueDefinition.DeprecationReason = reason; } parent.Values.Add(valueDefinition); } }
public InputObjectTypeExtension Create(IDescriptorContext context, InputObjectTypeExtensionNode node) { var preserveSyntaxNodes = context.Options.PreserveSyntaxNodes; var typeDefinition = new InputObjectTypeDefinition(node.Name.Value); typeDefinition.BindTo = node.GetBindingValue(); SdlToTypeSystemHelper.AddDirectives(typeDefinition, node); DeclareFields(typeDefinition, node.Fields, preserveSyntaxNodes); return(InputObjectTypeExtension.CreateUnsafe(typeDefinition)); }
public UnionTypeExtension Create(IDescriptorContext context, UnionTypeExtensionNode node) { var typeDefinition = new UnionTypeDefinition(node.Name.Value); typeDefinition.BindTo = node.GetBindingValue(); foreach (NamedTypeNode namedType in node.Types) { typeDefinition.Types.Add(TypeReference.Create(namedType)); } SdlToTypeSystemHelper.AddDirectives(typeDefinition, node); return(UnionTypeExtension.CreateUnsafe(typeDefinition)); }
public EnumType Create(IDescriptorContext context, EnumTypeDefinitionNode node) { var preserveSyntaxNodes = context.Options.PreserveSyntaxNodes; var typeDefinition = new EnumTypeDefinition( node.Name.Value, node.Description?.Value); typeDefinition.BindTo = node.GetBindingValue(); if (preserveSyntaxNodes) { typeDefinition.SyntaxNode = node; } SdlToTypeSystemHelper.AddDirectives(typeDefinition, node); DeclareValues(typeDefinition, node.Values, preserveSyntaxNodes); return(EnumType.CreateUnsafe(typeDefinition)); }
private static void DeclareFields( InputObjectTypeDefinition parent, IReadOnlyCollection <InputValueDefinitionNode> fields, bool preserveSyntaxNodes) { foreach (InputValueDefinitionNode inputField in fields) { var inputFieldDefinition = new InputFieldDefinition( inputField.Name.Value, inputField.Description?.Value, TypeReference.Create(inputField.Type), inputField.DefaultValue); inputFieldDefinition.BindTo = inputField.GetBindingValue(); if (preserveSyntaxNodes) { inputFieldDefinition.SyntaxNode = inputField; } SdlToTypeSystemHelper.AddDirectives(inputFieldDefinition, inputField); parent.Fields.Add(inputFieldDefinition); } }
private static void DeclareFieldArguments( ObjectFieldDefinition parent, FieldDefinitionNode field, bool preserveSyntaxNodes) { foreach (InputValueDefinitionNode argument in field.Arguments) { var argumentDefinition = new ArgumentDefinition( argument.Name.Value, argument.Description?.Value, TypeReference.Create(argument.Type), argument.DefaultValue); argumentDefinition.BindTo = argument.GetBindingValue(); if (preserveSyntaxNodes) { argumentDefinition.SyntaxNode = argument; } SdlToTypeSystemHelper.AddDirectives(argumentDefinition, argument); parent.Arguments.Add(argumentDefinition); } }
public UnionType Create(IDescriptorContext context, UnionTypeDefinitionNode node) { var preserveSyntaxNodes = context.Options.PreserveSyntaxNodes; var typeDefinition = new UnionTypeDefinition( node.Name.Value, node.Description?.Value); typeDefinition.BindTo = node.GetBindingValue(); if (preserveSyntaxNodes) { typeDefinition.SyntaxNode = node; } foreach (NamedTypeNode namedType in node.Types) { typeDefinition.Types.Add(TypeReference.Create(namedType)); } SdlToTypeSystemHelper.AddDirectives(typeDefinition, node); return(UnionType.CreateUnsafe(typeDefinition)); }