How to organize nodeDefinition for GraphQL Server as separate files for schema?

Uncategorized
Question: I have set up a graphql server with nodejs and separated the graphql schema definitions in separate files like Type, Mutations, Query and Subscriptions. |-GraphqlSchema |-mutations |-queries |-types Now I'm trying to add nodeDefitions to make the server a relay compatible one for the client. I'm not sure on which file to place the nodeDefinitions. If creating a NodeDefinition as separated file, I assume below problems:nodeinterface of NodeDefinition would have to use the resolver code as that of the one in query file. (redundant codes) If connectionTypes are to be defined, the nodeDefinition has to import the Types and the types inturn has to import NodeDefinition (inter-dependency). Any thoughts on organising the Graphql schema files with modularity would be appreciated. The working code is available in GitHub Repo Answer:…
Read More

Working with Realm and result JSON

Uncategorized
Question: I am new to realm and I am trying to use Realm in my project. Here I am trying to parse JSON and save it using realm. When I am trying to loop through the result array error occurs 'Attempting to modify object outside of a write transaction - call beginwritetransaction on an RLMRealm instance first' This is the JSON result:{"data":[{"id":1,"parent_id":0,"name":"JenniferMaenle","title":"Ms","phone":"","address":"Toled, ohio","email":"jlmaenle@aol.com","image":"44381525_2017.jpg","relation_id":5,"created_at":null,"updated_at":"2017-08-10 02:30:05"},{"id":2, "parent_id":1,"name":"Khadeeja","title":"","phone":"","address":"","email":"","image":"Khadeeja_2017-07-17.jpg","relation_id":2,"created_at":null,"updated_at":"2017-07-17 08:3:12"}]} I am trying to parse JSON and save it in the Realm database. Here is my try:class Person: Object { dynamic var name = "" dynamic var title = "" dynamic var address = "" } override func viewDidLoad() { super.viewDidLoad() self.add() } func add(){ guard let data = dataFromFile("ServerData") else { return } let persons = Person() do { if let json =…
Read More

Exception handling in ActionBlock

Uncategorized
Question: I have an ActionBlock which I send items fetched from db to a web api endpoint via HttpClient. Below code simulates my work public async static void Start() { ProcessQueue = new ActionBlock(async (item) => { await Process(item); }, processBlockOptions); while (!Stopped) { try { using (var connection = new SqlConnection(ConfigurationManager.AppSettings["Prod"])) { if (connection.State != System.Data.ConnectionState.Open) connection.Open(); DataTable table = QueueProcessorUtil.GetMessageBatch(connection); if (table != null && table.Rows.Count > 0) { foreach (var item in table.DataTableToList()) { QueueProcessorUtil.EndConversation(item.conversation_handle, connection); var ap = new ActionParam { QueueMessage = item }; /* using Completion to propagate exception */ ProcessQueue.Post(ap); await ProcessQueue.Completion; } } } } catch (Exception ex) { Console.WriteLine(ex.Message); Logger.Write(ex.Message); if (ex is HttpRequestException) { // Stop the service. Stopped = true; // Start pinging server PingService(ConfigurationManager.AppSettings["PingServiceTimeout"].ToString()); } } } }…
Read More

Simplify Multiple Variables in JavaScript [duplicate]

Uncategorized
Question: This question already has an answer here:How to define multiple variables on a single line? 5 answers How to simplify a set of vars? var q1 = 0; var q2 = 0; var q3 = 0; var q4 = 0; var q5 = 0; var q6 = 0; var q7 = 0; var q8 = 0; var q9 = 0; var q10 = 0; var counter = 0; or like this? var q1 = 0, q2 = 0, q3 = 0, q4 = 0, q5 = 0, q6 = 0, q7 = 0, q8 = 0, q9 = 0, q10 = 0, counter = 0; Is there any way around? Answer: If you use series variables. The best option is the array var q=[0,0,0,0,0,0,0,0,0,0] , counter=0; Read more
Read More