Esempio n. 1
0
        public void IntrospectedScalar_PropertyCheck()
        {
            var serverBuilder = new TestServerBuilder();

            serverBuilder.AddGraphType <string>();
            var server = serverBuilder.Build();

            var schema = new IntrospectedSchema(server.Schema);
            var scalar = GraphQLProviders.ScalarProvider.RetrieveScalar(typeof(string));

            var spected = new IntrospectedType(scalar);

            spected.Initialize(schema);

            Assert.AreEqual(scalar.Name, spected.Name);
            Assert.AreEqual(scalar.Description, spected.Description);
            Assert.AreEqual(scalar.Kind, spected.Kind);

            Assert.IsNull(spected.Fields);
            Assert.IsNull(spected.Interfaces);
            Assert.IsNull(spected.PossibleTypes);
            Assert.IsNull(spected.EnumValues);
            Assert.IsNull(spected.InputFields);
            Assert.IsNull(spected.OfType);
        }
Esempio n. 2
0
        public override NonNullable <IntrospectedType> Introspect(ISchemaRepository schemaRepository)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Kind   = TypeKind.NON_NULL;
            introspectedType.OfType = this.UnderlyingNullableType.Introspect(schemaRepository);

            return(introspectedType);
        }
Esempio n. 3
0
        internal static IntrospectedType CreateForNonNull(IntrospectedType underlyingType)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Kind   = TypeKind.NON_NULL;
            introspectedType.OfType = underlyingType;

            return(introspectedType);
        }
        public override NonNullable <IntrospectedType> Introspect(ISchemaRepository schemaRepository)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Name        = this.Name;
            introspectedType.Description = this.Description;
            introspectedType.Kind        = TypeKind.SCALAR;

            return(introspectedType);
        }
Esempio n. 5
0
        public static IntrospectedType CreateForScalar(GraphQLScalarType type)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Name        = type.Name;
            introspectedType.Description = type.Description;
            introspectedType.Kind        = TypeKind.SCALAR;

            return(introspectedType);
        }
        public override NonNullable <IntrospectedType> Introspect(ISchemaRepository schemaRepository)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Name        = this.Name;
            introspectedType.Description = this.Description;
            introspectedType.Kind        = TypeKind.ENUM;
            introspectedType.EnumValues  = this.Values.Select(e => e.Value.Introspect()).ToArray();

            return(introspectedType);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        internal static IntrospectedType CreateForList(GraphQLList type, IntrospectedType listItemType)
        {
            var introspectedType = new IntrospectedType();

            introspectedType.Name        = type.Name;
            introspectedType.Description = type.Description;
            introspectedType.Kind        = TypeKind.LIST;
            introspectedType.OfType      = listItemType;

            return(introspectedType);
        }
Esempio n. 9
0
        private MethodInfo[] GetNonPropertyMethods()
        {
            // no better way to do this (ie no flag that indicates getter/setter)
            var allMethods = new List <MethodInfo>(IntrospectedType.GetMethods());

            foreach (PropertyInfo pInfo in properties)
            {
                allMethods.Remove(pInfo.GetGetMethod());
                allMethods.Remove(pInfo.GetSetMethod());
            }
            return(allMethods.OrderBy(m => m, new SortActionsFirst(FacetFactorySet)).ToArray());
        }
Esempio n. 10
0
        public void Introspected_NotNullType_WhenSuppliedANotNullType_ThrowsException()
        {
            var serverBuilder = new TestServerBuilder();
            var server        = serverBuilder.AddGraphType <string>()
                                .Build();

            var schema = new IntrospectedSchema(server.Schema);

            schema.Rebuild();

            var scalar = GraphQLProviders.ScalarProvider.RetrieveScalar(typeof(string));

            var spected = schema.FindIntrospectedType(scalar);

            var wrapped = Introspection.WrapBaseTypeWithModifiers(spected, MetaGraphTypes.IsNotNull);

            Assert.Throws <GraphTypeDeclarationException>(() =>
            {
                var _ = new IntrospectedType(wrapped, TypeKind.NON_NULL);
            });
        }