{"id":15603423,"url":"https://github.com/codemeasandwich/graphql-query-builder","last_synced_at":"2025-09-08T07:31:11.999Z","repository":{"id":57253544,"uuid":"63492575","full_name":"codemeasandwich/graphql-query-builder","owner":"codemeasandwich","description":"a simple but powerful graphQL query builder","archived":false,"fork":false,"pushed_at":"2019-06-20T12:54:05.000Z","size":22,"stargazers_count":98,"open_issues_count":11,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-26T21:06:39.925Z","etag":null,"topics":["api","graphql","query-builder"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemeasandwich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-16T16:40:54.000Z","updated_at":"2024-08-30T03:44:47.000Z","dependencies_parsed_at":"2022-08-31T22:12:03.768Z","dependency_job_id":null,"html_url":"https://github.com/codemeasandwich/graphql-query-builder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fgraphql-query-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fgraphql-query-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fgraphql-query-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemeasandwich%2Fgraphql-query-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemeasandwich","download_url":"https://codeload.github.com/codemeasandwich/graphql-query-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232287402,"owners_count":18499949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","graphql","query-builder"],"created_at":"2024-10-03T03:03:14.697Z","updated_at":"2025-01-03T04:14:21.262Z","avatar_url":"https://github.com/codemeasandwich.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/codemeasandwich"],"categories":[],"sub_categories":[],"readme":"# graphql-query-builder\n\na simple but powerful graphQL query builder\n\n**info:**\n\n[![npm version](https://badge.fury.io/js/graphql-query-builder.svg)](https://badge.fury.io/js/graphql-query-builder)\n[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)\n[![pull requests welcome](https://img.shields.io/badge/Pull%20requests-welcome-pink.svg)](https://github.com/codemeasandwich/graphql-query-builder/pulls)\n[![GitHub stars](https://img.shields.io/github/stars/codemeasandwich/graphql-query-builder.svg?style=social\u0026label=Star)](https://github.com/codemeasandwich/graphql-query-builder)\n\n\n**tests:**\n\n[![build](https://api.travis-ci.org/codemeasandwich/graphql-query-builder.svg)](https://travis-ci.org/codemeasandwich/graphql-query-builder)\n[![Coverage Status](https://coveralls.io/repos/github/codemeasandwich/graphql-query-builder/badge.svg?branch=master)](https://coveralls.io/github/codemeasandwich/graphql-query-builder?branch=master)\n\n\n**quality:**\n\n[![Code Climate](https://codeclimate.com/github/codemeasandwich/graphql-query-builder/badges/gpa.svg)](https://codeclimate.com/github/codemeasandwich/graphql-query-builder)\n[![bitHound Overall Score](https://www.bithound.io/github/codemeasandwich/graphql-query-builder/badges/score.svg)](https://www.bithound.io/github/codemeasandwich/graphql-query-builder)\n[![Issue Count](https://codeclimate.com/github/codemeasandwich/graphql-query-builder/badges/issue_count.svg)](https://codeclimate.com/github/codemeasandwich/graphql-query-builder)\n[![Known Vulnerabilities](https://snyk.io/test/npm/graphql-query-builder/badge.svg)](https://snyk.io/test/npm/graphql-query-builder)\n\n### If this was helpful, [★ it on github](https://github.com/codemeasandwich/graphql-query-builder)\n\n*tested on [**NodeJS**](https://nodejs.org) and [**Webpack**](https://webpack.github.io)*\n\n\n## [Demo / Sandbox](https://tonicdev.com/codemeasandwich/57a0727c80254315001cb366) :thumbsup:\n\n [![Buy me a coffee](https://img.shields.io/badge/buy%20me-a%20coffee-orange.svg)](https://www.buymeacoffee.com/codemeasandwich)\n\n# Install\n\n`npm install graphql-query-builder`\n\n# Api\n\n``` js\nconst Query = require('graphql-query-builder');\n```\n\n### constructor\nquery/mutator you wish to use, and an alias or filter arguments.\n\n| Argument (**one** to **two**)  | Description\n|--- |---\n| String | the name of the query function\n| * String / Object | (**optional**) This can be an `alias` or `filter` values \n\n``` js\nlet profilePicture = new Query(\"profilePicture\",{size : 50});\n``` \n\n### setAlias\nset an alias for this result.\n\n| Argument | Description\n|--- |---\n| String | The alias for this result\n\n``` js\nprofilePicture.setAlias(\"MyPic\");\n``` \n\n### filter\nthe parameters to run the query against.\n\n| Argument | Description\n|--- |---\n| Object | An object mapping attribute to values\n\n``` js\nprofilePicture.filter({ height : 200, width : 200});\n``` \n\n### find\noutlines the properties you wish to be returned from the query.\n\n| Argument (**one** to **many**) | Description\n|--- |---\n| String or Object |  representing each attribute you want Returned\n| ... | *same as above*\n\n``` js\n    profilePicture.find( { link : \"uri\"}, \"width\", \"height\");\n``` \n\n### toString\nreturn to the formatted query string\n\n``` js\n  // A (ES6)\n  `${profilePicture}`;\n  // B\n  profilePicture+'';\n  // C\n  profilePicture.toString();\n``` \n\n## run samples\n\n``` bash\nnode example/simple.js\n```\n\n# Example\n\n``` js \nvar Query = require('graphql-query-builder');\n\n// example of nesting Querys\nlet profilePicture = new Query(\"profilePicture\",{size : 50});\n    profilePicture.find( \"uri\", \"width\", \"height\");\n    \nlet user = new Query(\"user\",{id : 123});\n    user.find([\"id\", {\"nickname\":\"name\"}, \"isViewerFriend\",  {\"image\":profilePicture}])\n    \n    console.log(user)\n    /*\n     user( id:123 ) {\n    id,\n    nickname : name,\n    isViewerFriend,\n    \n    image : profilePicture( size:50 ) {\n        uri,\n        width,\n        height\n    }\n  }\n    */\n    \n// And another example\n\nlet MessageRequest = { type:\"chat\", message:\"yoyo\",\n                   user:{\n                            name:\"bob\",\n                            screen:{\n                                    height:1080,\n                                    width:1920\n                                    }\n                    },\n                    friends:[\n                             {id:1,name:\"ann\"},\n                             {id:2,name:\"tom\"}\n                             ]\n                    };\n                    \nlet MessageQuery = new Query(\"Message\",\"myPost\");\n    MessageQuery.filter(MessageRequest);\n    MessageQuery.find({ messageId : \"id\"}, {postedTime : \"createTime\" });\n    \n    console.log(MessageQuery);\n    \n    /*\n    myPost:Message( type:\"chat\",\n                    message:\"yoyo\",\n                    user:{name:\"bob\",screen:{height:1080,width:1920}},\n                    friends:[{id:1,name:\"ann\"},{id:2,name:\"tom\"}])\n        {\n            messageId : id,\n            postedTime : createTime\n        }\n    */\n\n    // Simple nesting\n    \n    let user = new Query(\"user\");\n        user.find([{\"profilePicture\":[\"uri\", \"width\", \"height\"]}])\n    \n    /* \n    user {\n      profilePicture {\n        uri,\n        width,\n        height\n       }\n     }\n    */ \n    \n    // Simple nesting with rename\n    \n    let user = new Query(\"user\");\n        user.find([{\"image\":{\"profilePicture\":[\"uri\", \"width\", \"height\"]}}])\n    \n    /* \n    user {\n      image : profilePicture {\n        uri,\n        width,\n        height\n       }\n     }\n    */ \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fgraphql-query-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemeasandwich%2Fgraphql-query-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemeasandwich%2Fgraphql-query-builder/lists"}