{"action":"created","issue":{"url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/3","repository_url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support","labels_url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/3/comments","events_url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/3/events","html_url":"https://github.com/neueda/jetbrains-plugin-graph-database-support/issues/3","id":163218682,"number":3,"title":"Programmatic usage","user":{"login":"Jiropole","id":1165646,"avatar_url":"https://avatars.githubusercontent.com/u/1165646?v=3","gravatar_id":"","url":"https://api.github.com/users/Jiropole","html_url":"https://github.com/Jiropole","followers_url":"https://api.github.com/users/Jiropole/followers","following_url":"https://api.github.com/users/Jiropole/following{/other_user}","gists_url":"https://api.github.com/users/Jiropole/gists{/gist_id}","starred_url":"https://api.github.com/users/Jiropole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jiropole/subscriptions","organizations_url":"https://api.github.com/users/Jiropole/orgs","repos_url":"https://api.github.com/users/Jiropole/repos","events_url":"https://api.github.com/users/Jiropole/events{/privacy}","received_events_url":"https://api.github.com/users/Jiropole/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-30T17:18:58Z","updated_at":"2016-07-03T08:46:46Z","closed_at":null,"body":"Apologies if this is off-topic.\r\n\r\nI dig the concept of writing all my queries in a syntax highlighting and auto-completion context. But executing canned queries has limited use in my case (developing an API server). I'd rather have granular access to query *templates* defined in the .cyp file, applying dynamic parameters at runtime. I might want to have predefined query clauses, as well as full queries.\r\n\r\nIn my fantasy, I might be able to easily build a parametric query:\r\n\r\n```\r\nsession.run(cypFile.queryWithKey(key, queryParameters));\r\n```\r\n\r\nor assemble a query from standard clauses:\r\n\r\n```    \r\nsession.run(cypFile.queryWithClauseKeys(['key1', 'key2', 'key3'], stringInjectionParameters, queryParameters));\r\n```\r\n\r\n*In this case, query string is manipulated client-side with stringInjectionParameters (and simple syntax for identifying them in the string template, not sure what wouldn't conflict with standard Cypher), before parametric query is produced.*\r\n\r\nDoes anyone have any recommendations for this kind of workflow? Maybe there already a meta-language above .cyp that does what I'm talking about, or if not, seems like it could just be as \"simple\" as adding a key-value mapping structure around the queries, but still have the file be parsable by the .cyp interpreter.\r\n\r\nOr I can get off your lawn...!"},"comment":{"url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/comments/230142555","html_url":"https://github.com/neueda/jetbrains-plugin-graph-database-support/issues/3#issuecomment-230142555","issue_url":"https://api.github.com/repos/neueda/jetbrains-plugin-graph-database-support/issues/3","id":230142555,"user":{"login":"FylmTM","id":626772,"avatar_url":"https://avatars.githubusercontent.com/u/626772?v=3","gravatar_id":"","url":"https://api.github.com/users/FylmTM","html_url":"https://github.com/FylmTM","followers_url":"https://api.github.com/users/FylmTM/followers","following_url":"https://api.github.com/users/FylmTM/following{/other_user}","gists_url":"https://api.github.com/users/FylmTM/gists{/gist_id}","starred_url":"https://api.github.com/users/FylmTM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FylmTM/subscriptions","organizations_url":"https://api.github.com/users/FylmTM/orgs","repos_url":"https://api.github.com/users/FylmTM/repos","events_url":"https://api.github.com/users/FylmTM/events{/privacy}","received_events_url":"https://api.github.com/users/FylmTM/received_events","type":"User","site_admin":false},"created_at":"2016-07-03T08:46:46Z","updated_at":"2016-07-03T08:46:46Z","body":"Hi @Jiropole,\r\n\r\nLong story short - I don't know any library/meta-language that can offer you such functionality.\r\n\r\nSome thoughts from top of my head: you can use your programming language to do exactly that.\r\n\r\nI am Java developer, so I will give you some java examples.\r\nI will simplify code in several places.\r\n\r\n-------\r\n\r\nLet's create `CypherQueryRepository`:\r\n\r\n```java\r\nclass CypherQueryRepository {\r\n    private Map<String, String> templates;\r\n\r\n    public void add(String key, String template) {\r\n        templates.put(key, template);\r\n    }\r\n\r\n    public String query(String.. keys) {\r\n        return Arrays.stream(keys)\r\n                .reduce(\"\", (result, key) -> result + \" \" + templates.get(key))\r\n    }\r\n}\r\n```\r\n\r\nAnd usage will be:\r\n```java\r\nCypherQueryRepository repository = ...\r\nrepository.add(\"key1\", \"...\");\r\nrepository.add(\"key2\", \"...\");\r\nrepository.add(\"key3\", \"...\");\r\nrepository.add(\"key4\", \"...\");\r\n\r\n// Execute query\r\nsession.run(repository.query(\"key1\"));\r\nsession.run(repository.query(\"key1\", \"key2\", \"key3\"));\r\n```\r\n\r\nNotes: \r\n- Such workflow does not ensures that resulting cypher will be valid.\r\n- You can use Cypher injection in Java parameters to get highlight & autocompletion support (we will fix bug that does not allows you to run injected strings on next week)\r\n- You should never use string replacements in Cypher query. Almost everywhere you can use parameters (except labels)."}}
{"actor":{"display_login":"FylmTM"}}