Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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()
                }
            };
        }