{"id":18961689,"url":"https://github.com/yoonit-labs/javascript-yoonit-utils","last_synced_at":"2025-04-19T11:41:03.470Z","repository":{"id":42238135,"uuid":"343917058","full_name":"Yoonit-Labs/javascript-yoonit-utils","owner":"Yoonit-Labs","description":"Couple of functions in JS to speed up development and give some help","archived":false,"fork":false,"pushed_at":"2023-03-05T22:16:38.000Z","size":3349,"stargazers_count":27,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"development","last_synced_at":"2025-04-16T04:45:21.941Z","etag":null,"topics":["graphql","hacktoberfest","javascript","tools"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"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/Yoonit-Labs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-02T21:26:43.000Z","updated_at":"2024-01-04T16:55:19.000Z","dependencies_parsed_at":"2025-04-16T04:50:48.684Z","dependency_job_id":null,"html_url":"https://github.com/Yoonit-Labs/javascript-yoonit-utils","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoonit-Labs%2Fjavascript-yoonit-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoonit-Labs%2Fjavascript-yoonit-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoonit-Labs%2Fjavascript-yoonit-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoonit-Labs%2Fjavascript-yoonit-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yoonit-Labs","download_url":"https://codeload.github.com/Yoonit-Labs/javascript-yoonit-utils/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249685290,"owners_count":21310577,"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":["graphql","hacktoberfest","javascript","tools"],"created_at":"2024-11-08T14:14:02.556Z","updated_at":"2025-04-19T11:41:03.418Z","avatar_url":"https://github.com/Yoonit-Labs.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003eYoonit Utils\u003c/h1\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\n\t\u003cimg src=\"https://img.shields.io/npm/v/@yoonit/utils?color=lightgrey\u0026style=for-the-badge\u0026logo=npm\"/\u003e\r\n\t\u003cimg src=\"https://img.shields.io/npm/dm/@yoonit/utils?color=lightgrey\u0026logo=npm\u0026style=for-the-badge\"/\u003e\r\n\t\u003cimg src=\"https://img.shields.io/badge/Javascript-35495E?color=lightgrey\u0026style=for-the-badge\u0026logo=javascript\"/\u003e\r\n\t\u003cimg src=\"https://img.shields.io/npm/l/@yoonit/utils?color=lightgrey\u0026style=for-the-badge\"/\u003e\r\n\u003c/p\u003e\r\n\r\n#### Couple of functions in JS to speed up development and give some help with:\r\n- A GraphQl Query Builder\r\n- A GraphQl Mutation Builder\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\t\u003ch3\u003eSponsors\u003c/h3\u003e\r\n\t\u003ctable\u003e\r\n\t\t\u003ctbody\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd\u003e\r\n\t\t\t\t\t\u003cb\u003ePlatinum\u003c/b\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd align=\"center\" valign=\"middle\"\u003e\r\n\t\t\t\t\t\u003ca href=\"https://cyberlabs.ai\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/Yoonit-Labs/javascript-yoonit-utils/development/sponsor_cyberlabs.png\" width=\"300\" /\u003e\u003c/a\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\u003c/tbody\u003e\r\n\t\u003c/table\u003e\r\n\t\u003ch5\u003e\u003ca href=\"mailto:about@yoonit.dev\"\u003eBecome a sponsor!\u003c/a\u003e\u003c/h5\u003e\r\n\u003c/div\u003e\r\n\r\n## Table Of Contents\r\n\r\n* [Installation](#installation)\r\n* [Usage](#usage)\r\n    * [Query Builder](#query-builder)\r\n    * [Mutation Builder](#mutation-builder)\r\n* [Advanced Usage](#advanced-usage)\r\n* [Using for real](#using-it-for-real)\r\n* [Contribute](#to-contribute-and-make-it-better)\r\n\r\n## Installation\r\n\r\n```javascript\r\nnpm i -s @yoonit/utils\r\n```\r\n\r\n## Usage\r\nWe used a functional technique called currying at the main constructor function, this means that we pass a subset of arguments and each function returns a function that uses the next subset of arguments.\r\n\r\nThe first parameters is a string and its the the endpoint name (such as 'getUsers'), it returns the function that uses the next parameter, the arguments object. This function will build the arguments body for your query/mutation and will return another function. This third function uses the third parameter you need to pass, the expected response fields. This will build the response filds and will return you query/mutation ready to use.\r\nYou can use the builders without a arguments object, but you need to pass the endpoint name and the response fields, otherwise it will return false and a warning.\r\n\r\nParameters: \r\n- Endpoint Name e.g., 'getUsers'\r\n- Object parameters e.g., '{ value: 'value' }'\r\n- Expected response fields e.g, 'status', 'message'\r\n\r\n\r\n### Query Builder\r\n\r\n```javascript\r\nimport { graphql } from '@yoonit/utils'\r\n\r\nconst query = graphql.query('getUsers')({ value: 'value', valueTwo: 123 })('status', 'message', 'messageTwo')\r\n```\r\nOutput\r\n```\r\nquery {\r\n  getUsers (\r\n    value: \"value\",\r\n    valueTwo: 123,\r\n  ){\r\n    status,\r\n    message,\r\n    messageTwo\r\n  }\r\n}\r\n```\r\n\r\n### Mutation Builder\r\n\r\n```javascript\r\nimport { graphql } from '@yoonit/utils'\r\n\r\nconst mutation = graphql.mutation('createUser')(name: 'Mutation', surname: 'Builder')('status', 'message')\r\n```\r\nOutput\r\n```\r\nmutation {\r\n  createUser (\r\n    name: \"Mutation\",\r\n    surname: \"Builder\"\r\n  ){\r\n    status,\r\n    message\r\n  }\r\n}\r\n```\r\n\r\n## Advanced Usage\r\n\r\nOur builders also suports nested response fields and arrays on arguments object, see beelow how to use it:\r\n\r\n```javascript\r\nimport { graphql } from '@yoonit/utils'\r\n\r\nconst mutation = graphql.mutation('createUser')({ value: ['value', '123', 'John Doe']})('status', 'message', { 'messageTwo': ['messageTitle', 'messageBody', { 'messageAlt': 'test' }, { 'messageAtt': ['att1', 'att2'] }]})\r\n```\r\n\r\nOutput\r\n```\r\nmutation {\r\n  createUser (\r\n    value: [\r\n      'value',\r\n      '123',\r\n      'John Doe'\r\n    ],\r\n  ){\r\n    status,\r\n    message,\r\n    messageTwo {\r\n      messageTitle,\r\n      messageBody,\r\n      messageAlt {\r\n        test\r\n      },\r\n      messageAtt {\r\n        att1,\r\n        att2\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n## Using it for real\r\nYou can use it with js fetch or any other HTTP client you like.\r\nSee below how to use it with Fetch\r\n\r\n```javascript\r\nimport { graphql } from '@yoonit/utils'\r\n\r\nconst body = graphql.mutation('createUser')({value: ['value', '123', 'John Doe'] })('status', 'message', { 'messageTwo': ['messageTitle', 'messageBody', { 'messageAlt': 'test' }, { 'messageAtt': ['att1', 'att2'] }]})\r\n\r\nfetch('http://yourapi:5000', {\r\n  method: 'POST',\r\n  headers: { 'Content-Type': 'application/json' },\r\n  body // Use the builder response here, as your body :) \r\n  })\r\n})\r\n```\r\n\r\n\r\n## To contribute and make it better\r\n\r\nClone the repo, change what you want and send PR.\r\nFor commit messages we use \u003ca href=\"https://www.conventionalcommits.org/\"\u003eConventional Commits\u003c/a\u003e.\r\n\r\nContributions are always welcome!\r\n\r\n[\u003cimg src=\"https://contrib.rocks/image?repo=Yoonit-Labs/javascript-yoonit-utils\"/\u003e](https://github.com/Yoonit-Labs/javascript-yoonit-utils/graphs/contributors)\r\n\r\n---\r\n\r\nCode with ❤ by the [**Yoonit**](https://yoonit.dev/) Team\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoonit-labs%2Fjavascript-yoonit-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoonit-labs%2Fjavascript-yoonit-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoonit-labs%2Fjavascript-yoonit-utils/lists"}