{"id":25925437,"url":"https://github.com/miniql/miniql-lazy","last_synced_at":"2026-05-29T20:31:39.649Z","repository":{"id":143762302,"uuid":"286667282","full_name":"miniql/miniql-lazy","owner":"miniql","description":"Creates a MiniQL query resolver for lazily loaded data.","archived":false,"fork":false,"pushed_at":"2022-05-30T09:20:53.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T23:34:31.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/miniql.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"ashleydavis"}},"created_at":"2020-08-11T06:44:56.000Z","updated_at":"2021-10-02T00:59:06.000Z","dependencies_parsed_at":"2023-06-07T23:00:24.116Z","dependency_job_id":null,"html_url":"https://github.com/miniql/miniql-lazy","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"820d5e660d51946f1e5579e386eb872a202f665b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniql%2Fminiql-lazy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniql%2Fminiql-lazy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniql%2Fminiql-lazy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miniql%2Fminiql-lazy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miniql","download_url":"https://codeload.github.com/miniql/miniql-lazy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241723392,"owners_count":20009412,"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":[],"created_at":"2025-03-03T18:48:25.531Z","updated_at":"2026-05-29T20:31:39.633Z","avatar_url":"https://github.com/miniql.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ashleydavis"],"categories":[],"sub_categories":[],"readme":"# @miniql/lazy\n\nA [MiniQL](https://github.com/miniql/miniql) query resolver lazily loaded data. This MiniQL plugin is designed to be used to build other plugins.\n\nAny problems? Please log an issue on this repo.\n\nLove this? Please [star the repo](https://github.com/miniql/miniql) and [support my work](https://www.codecapers.com.au/about#support-my-work)\n\n## Using it\n\nInstall the modules in your Node.js project:\n\n```bash\nnpm install --save miniql\nnpm install --save @miniql/lazy\n```\n\nImport the modules (JavaScript):\n\n```javascript\nconst { miniql } = require(\"miniql\");\nconst { createQueryResolver } = require(\"@miniql/lazy\");\n```\n\nImport the modules (TypeScript):\n\n```typescript\nimport { miniql } from \"miniql\";\nimport { createQueryResolver } from \"@miniql/lazy\";\n```\n\nThen create a configuration for your data:\n\n```javascript\n    //\n    // Configures the query resolver.\n    //\n    const queryConfig = {\n        species: {\n            primaryKey: \"name\",\n            nested: {\n                homeworld: {\n                    parentKey: \"homeworld\",\n                    from: \"planet\",\n                },\n            },\n        },\n        planet: {\n            primaryKey: \"name\",\n            nested: {\n                species: {\n                    foreignKey: \"homeworld\",\n                },\n            },\n        },\n    };\n```\n\nNow create a lazy data loader:\n\n```javascript\n    const dataLoader = {\n\n        //\n        // Loads a single entity.\n        //\n        loadSingleEntity = async (entityTypeName: string, primaryKey: string, entityId: string): Promise\u003cany\u003e =\u003e {\n            const entity = // Load a single of type 'entityTypeName' with a value in its field 'primaryKey' of value 'entityId'.\n            return entity;\n        },\n\n        //\n        // Load the set of entities.\n        //\n        async loadEntities(entityTypeName: string): Promise\u003cany[]\u003e {\n            const entities = // Load all entities of type 'entityTypeName'.\n            return entities;\n        },\n    };\n```\n\nFinally create a lazy query resolver with your configuration and data loader:\n\n```javascript\n    // \n    // Creates a query resolver for lazy loadeed data.\n    //\n    const queryResolver = await createQueryResolver(queryConfig, dataLoader);\n```\n\nNow you can make queries against the lazily loaded dataset, for example:\n\n```javascript\n    const query = {\n        get: {\n            species: { // Query for \"species\" entity.\n            \n                // No arguments gets all entities.\n\n                resolve: {\n                    homeworld: { // Resolves the homeworld of each species as a nested lookup.\n                    },\n                }\n            },\n        },\n    };\n\n    // Invokes MiniQL.\n    const result = await miniql(query, queryResolver, {});  \n\n    // Displays the query result.\n    console.log(JSON.stringify(result, null, 4));\n```\n\nPlease see [MiniQL](https://github.com/miniql/miniql) for more information on how to make queries.\n\nDon't forget to [star the repo](https://github.com/miniql/miniql) and [follow the developer on Twitter](https://twitter.com/codecapers).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiql%2Fminiql-lazy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminiql%2Fminiql-lazy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminiql%2Fminiql-lazy/lists"}