Пример #1
0
        public void FinalizeTypes(SchemaContext context)
        {
            // register types and their dependencies
            RegisterTypes(context);

            // finalize and register .net type to schema type bindings
            RegisterTypeBindings(context);

            // finalize and register field resolver bindings
            RegisterFieldResolvers(context);

            // compile resolvers and finalize types
            _errors.AddRange(context.CompleteTypes());
        }
Пример #2
0
        public void FinalizeTypes(SchemaContext context, string queryTypeName)
        {
            // register types and their dependencies
            RegisterTypes(context, queryTypeName);

            // finalize and register .net type to schema type bindings
            RegisterTypeBindings(context);

            // finalize and register field resolver bindings
            RegisterFieldResolvers(context);

            // register state object descriptors
            RegisterStateObjects(context);

            // compile resolvers and finalize types
            _errors.AddRange(context.CompleteTypes());
        }
Пример #3
0
        public void BindResolverCollectionToObjectTypeImplicitly()
        {
            // arrange
            SchemaContext schemaContext = new SchemaContext();

            StringType stringType = new StringType();
            ObjectType dummyType  = new ObjectType(new ObjectTypeConfig
            {
                Name   = "TestObjectA",
                Fields = new[]
                {
                    new Field(new FieldConfig
                    {
                        Name = "a", Type =
                            t => stringType
                    }),
                    new Field(new FieldConfig
                    {
                        Name = "b",
                        Type = t => stringType
                    })
                }
            });

            schemaContext.Types.RegisterType(stringType);
            schemaContext.Types.RegisterType(dummyType);

            // act
            SchemaConfiguration configuration = new SchemaConfiguration();

            configuration.BindResolver <TestResolverCollectionA>().To <TestObjectA>();

            bool hasErrors = configuration.RegisterTypes(schemaContext).Any();

            configuration.RegisterResolvers(schemaContext);
            hasErrors = schemaContext.CompleteTypes().Any() || hasErrors;

            // assert
            Assert.False(hasErrors);
            Assert.NotNull(schemaContext.Resolvers.GetResolver("TestObjectA", "a"));
            Assert.NotNull(schemaContext.Resolvers.GetResolver("TestObjectA", "b"));
            Assert.Null(schemaContext.Resolvers.GetResolver("Dummy", "x"));
        }