public static ISchema MakeExecutableSchemaWithIntrospection( SchemaBuilder builder, IResolverMap resolvers, ISubscriberMap subscribers = null, IReadOnlyDictionary <string, IValueConverter> converters = null, IReadOnlyDictionary <string, CreateDirectiveVisitor> directives = null) { // add converters if (converters != null) { UseConverters(builder, converters); } builder.UseResolversAndSubscribers(resolvers, subscribers); if (directives != null) { builder.ApplyDirectives(directives); } var schema = builder.Build(); var introspection = Introspect.Schema(schema); return(new SchemaBuilder() .Merge(schema, introspection) .Build()); }
public async Task Introspection_should_pass() { /* Given */ var schema = new SchemaBuilder() .Sdl(@" input InputItem { foo: [String] } type Mutation { createItem(input: InputItem!): ID } type Query { field : String } schema { query: Query mutation: Mutation } ") .Build(); var introspectionSchema = Introspect.Schema(schema); /* When */ var result = await Executor.ExecuteAsync(new ExecutionOptions() { Schema = introspectionSchema, Document = Parser.ParseDocument(Introspect.DefaultQuery) }); /* Then */ var types = (List <object>)result.Select("__schema", "types"); foreach (var type in types) { var typeDictionary = (Dictionary <string, object>)type; if ((string)typeDictionary["name"] == "InputItem") { var inputFields = (List <object>)typeDictionary["inputFields"]; foreach (var inputField in inputFields) { var inputFieldDictionary = (Dictionary <string, object>)inputField; if ((string)inputFieldDictionary["name"] == "foo") { var defaultValue = inputFieldDictionary["defaultValue"]; Assert.Null(defaultValue); } } } } }
private async Task <ISchema> Create(ICacheEntry cacheEntry) { cacheEntry.SetSlidingExpiration(TimeSpan.FromHours(6)); try { // create channelsSchema by introspecting channels service var channelsLink = Links.SignalROrHttp( _configuration["Remotes:Channels"], _configuration["Remotes:ChannelsHttp"], _accessor); var channelsSchema = RemoteSchemaTools.MakeRemoteExecutable( await new SchemaBuilder() .ImportIntrospectedSchema(channelsLink), channelsLink); // create messagesSchema by introspecting messages service var messagesLink = Links.SignalR( _configuration["Remotes:Messages"], _accessor); var messagesSchema = RemoteSchemaTools.MakeRemoteExecutable( await new SchemaBuilder() .ImportIntrospectedSchema(messagesLink), messagesLink); // combine schemas into one var schema = new SchemaBuilder() .Merge(channelsSchema, messagesSchema) .Build(); // introspect and merge with schema var introspection = Introspect.Schema(schema); return(new SchemaBuilder() .Merge(schema, introspection) .Build()); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task Query_Introspection() { /* Given */ var query = Introspect.DefaultQuery; var schema = await _sut.GetOrAdd(); var introspectionSchema = Introspect.Schema(schema); /* When */ var result = await Executor.ExecuteAsync(new ExecutionOptions() { Schema = introspectionSchema, Document = query }); /* Then */ Assert.Null(result.Errors); }
public static ISchema MakeExecutableSchemaWithIntrospection( SchemaBuilder builder, IResolverMap resolvers, ISubscriberMap subscribers = null, Dictionary <string, CreateDirectiveVisitor> directives = null) { UseResolversAndSubscribers(builder, resolvers, subscribers); if (directives != null) { UseDirectives(builder, directives); } var schema = builder.Build(); var introspection = Introspect.Schema(schema); return(new SchemaBuilder() .Merge(schema, introspection) .Build()); }