コード例 #1
0
 private static string PrintEnum(GraphQLEnumType type)
 {
     return
         (PrintDescription(type) +
          $"enum {type.Name} {{\n" +
          $"{PrintEnumValues(type.Values.Values)}\n}}");
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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");
        }
コード例 #4
0
 private IntrospectedType IntrospectEnumType(GraphQLEnumType type)
 {
     return(IntrospectedType.CreateForEnum(type, GraphQLEnumValue.GetEnumValuesFor(type.EnumType)));
 }