private static string PrintEnum(GraphQLEnumType type) { return (PrintDescription(type) + $"enum {type.Name} {{\n" + $"{PrintEnumValues(type.Values.Values)}\n}}"); }
internal static IntrospectedType CreateForEnum(GraphQLEnumType type, GraphQLEnumValue[] enumValues) { var introspectedType = new IntrospectedType(); introspectedType.Name = type.Name; introspectedType.Description = type.Description; introspectedType.Kind = TypeKind.ENUM; introspectedType.EnumValues = enumValues; return(introspectedType); }
public void ConvertsEnumValuesAccordingToInputCoercionRules() { var testEnum = new GraphQLEnumType <TestEnum>("TestColor", ""); this.schemaRepository.AddKnownType(testEnum); this.AreEqual(TestEnum.RED, testEnum, "RED"); this.AreEqual(TestEnum.BLUE, testEnum, "BLUE"); this.AreEqual(TestEnum.NULL, testEnum, "NULL"); this.AreEqual(null, testEnum, "null"); this.IsInvalid(testEnum, "3"); this.IsInvalid(testEnum, "\"BLUE\""); this.IsInvalid(testEnum, "UNDEFINED"); }
private IntrospectedType IntrospectEnumType(GraphQLEnumType type) { return(IntrospectedType.CreateForEnum(type, GraphQLEnumValue.GetEnumValuesFor(type.EnumType))); }