Esempio n. 1
0
        private static IReadOnlySchemaOptions ExecuteSchemaConfiguration(
            SchemaContext context,
            Action <ISchemaConfiguration> configure,
            List <SchemaError> errors)
        {
            try
            {
                // configure resolvers, custom types and type mappings.
                var configuration = new SchemaConfiguration(
                    context.ServiceManager.RegisterServiceProvider,
                    context.Types);

                configure(configuration);

                var options       = new ReadOnlySchemaOptions(configuration.Options);
                var typeFinalizer = new TypeFinalizer(configuration);
                typeFinalizer.FinalizeTypes(context, options.QueryTypeName);
                errors.AddRange(typeFinalizer.Errors);

                return(options);
            }
            catch (Exception ex)
            {
                throw new SchemaException(new[]
                {
                    new SchemaError(ex.Message, null, ex)
                });
            }
        }
Esempio n. 2
0
        public void Copy_Options_Defaults()
        {
            // arrange
            var options = new SchemaOptions();

            // act
            var copied = new ReadOnlySchemaOptions(options);

            // assert
            copied.MatchSnapshot();
        }
        public void Copy_Options()
        {
            // arrange
            var options = new SchemaOptions
            {
                QueryTypeName          = "A",
                MutationTypeName       = "B",
                SubscriptionTypeName   = "C",
                StrictValidation       = false,
                UseXmlDocumentation    = false,
                DefaultBindingBehavior = BindingBehavior.Explicit,
                FieldMiddleware        = FieldMiddlewareApplication.AllFields
            };

            // act
            var copied = new ReadOnlySchemaOptions(options);

            // assert
            copied.MatchSnapshot();
        }