public static void Initialize() { if (StarWarsHttpServer != null) //already initialized { return; } if (File.Exists(LogFilePath)) { File.Delete(LogFilePath); } // create server and Http graphQL server var app = new StarWarsApp(); var starWarsServer = new GraphQLServer(app); starWarsServer.RegisterModules(new StarWarsApiModule()); StarWarsHttpServer = new GraphQLHttpServer(starWarsServer); StartWebHost(); // Write schema doc to file var schemaDoc = starWarsServer.Model.SchemaDoc; File.WriteAllText("_starWarsSchema.txt", schemaDoc); Client = new GraphQLClient(GraphQLEndPointUrl); Client.RequestCompleted += Client_RequestCompleted; }
private GraphQLHttpServer CreateGraphQLHttpServer() { var app = new StarWarsApp(); var server = new GraphQLServer(app); server.RegisterModules(new StarWarsApiModule()); return(new GraphQLHttpServer(server)); }
private GraphQLHttpServer CreateGraphQLHttpServer() { // create server and Http graphQL server var thingsBizApp = new ThingsApp(); var thingsServer = new GraphQLServer(thingsBizApp); var thingsModule = new ThingsGraphQLModule(); thingsServer.RegisterModules(thingsModule); var server = new GraphQLHttpServer(thingsServer); return(server); }
public static void Init() { if (ThingsServer != null) { return; } if (File.Exists(LogFilePath)) { File.Delete(LogFilePath); } try { var thingsBizApp = new ThingsApp(); var thingsModule = new ThingsGraphQLModule(); ThingsServer = new GraphQLServer(thingsBizApp); ThingsServer.RegisterModules(thingsModule); ThingsServer.Initialize(); ThingsServer.Events.RequestCompleted += ThingsServer_RequestCompleted; } catch (ServerStartupException sEx) { LogText(sEx.ToText() + Environment.NewLine); LogText(sEx.GetErrorsAsText()); throw; } // Printout var schemaGen = new SchemaDocGenerator(); var schemaDoc = schemaGen.GenerateSchema(ThingsServer.Model); File.WriteAllText("_thingsApiSchema.txt", schemaDoc); _serializerSettings = new JsonSerializerSettings() { Formatting = Formatting.Indented, ContractResolver = new DefaultContractResolver() { NamingStrategy = new CamelCaseNamingStrategy() } }; }