public void AddSubscriptionServer_RegistrationChecks() { using var restorePoint = new GraphQLProviderRestorePoint(); // ensure the runtime is in a default state (just in case the statics got messed up) GraphQLProviders.TemplateProvider = new DefaultTypeTemplateProvider(); GraphQLProviders.GraphTypeMakerProvider = new DefaultGraphTypeMakerProvider(); GraphQLMvcSchemaBuilderExtensions.Clear(); var serviceCollection = new ServiceCollection(); var returned = serviceCollection.AddGraphQL(options => { options.AddGraphType <FanController>(); }) .AddSubscriptionServer(); this.EnsureSubscriptionServerRegistrations(serviceCollection.BuildServiceProvider()); }
public void ExplicitDeclarationOfPerRequestAuthorizationAddsServerSuccessfully() { // setup the server with a hard declaration of nothing using var restorePoint = new GraphQLProviderRestorePoint(); // ensure the runtime is in a default state (just in case the statics got messed up) GraphQLProviders.TemplateProvider = new DefaultTypeTemplateProvider(); GraphQLProviders.GraphTypeMakerProvider = new DefaultGraphTypeMakerProvider(); GraphQLMvcSchemaBuilderExtensions.Clear(); var serviceCollection = new ServiceCollection(); var returned = serviceCollection.AddGraphQL(options => { options.AddGraphType <FanController>(); options.AuthorizationOptions.Method = AuthorizationMethod.PerRequest; }) .AddSubscriptionServer(); this.EnsureSubscriptionServerRegistrations(serviceCollection.BuildServiceProvider()); }
public void ExplicitDeclarationOfPerFieldAuthorizationFailsServerCreation() { // setup the server with a hard declaration of nothing using var restorePoint = new GraphQLProviderRestorePoint(); // ensure the runtime is in a default state (just in case the statics got messed up) GraphQLProviders.TemplateProvider = new DefaultTypeTemplateProvider(); GraphQLProviders.GraphTypeMakerProvider = new DefaultGraphTypeMakerProvider(); GraphQLMvcSchemaBuilderExtensions.Clear(); var serviceCollection = new ServiceCollection(); var schemaBuilder = serviceCollection.AddGraphQL(options => { options.AddGraphType <FanController>(); options.AuthorizationOptions.Method = AuthorizationMethod.PerField; }); // server should value to generate Assert.Throws <ApolloSubscriptionServerException>( () => { schemaBuilder.AddSubscriptionServer(); }); }
public void TearDown() { GraphQLMvcSchemaBuilderExtensions.Clear(); GraphQLProviders.TemplateProvider.Clear(); GraphQLProviders.TemplateProvider.CacheTemplates = false; }