Example #1
0
        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;
        }
Example #2
0
        private GraphQLHttpServer CreateGraphQLHttpServer()
        {
            var app    = new StarWarsApp();
            var server = new GraphQLServer(app);

            server.RegisterModules(new StarWarsApiModule());
            return(new GraphQLHttpServer(server));
        }
Example #3
0
        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);
        }
Example #4
0
        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()
                }
            };
        }