{"id":13452523,"url":"https://github.com/birkir/graphql-mst","last_synced_at":"2025-04-12T12:03:18.264Z","repository":{"id":137962724,"uuid":"169494090","full_name":"birkir/graphql-mst","owner":"birkir","description":"Convert GraphQL to mobx-state-tree models","archived":false,"fork":false,"pushed_at":"2019-02-07T18:47:57.000Z","size":260,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T06:43:28.239Z","etag":null,"topics":["converter","graphql","mobx","mobx-state-tree","mst","parser","typescript"],"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/birkir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-02-06T23:41:32.000Z","updated_at":"2021-08-13T17:40:50.000Z","dependencies_parsed_at":"2023-03-22T05:50:04.264Z","dependency_job_id":null,"html_url":"https://github.com/birkir/graphql-mst","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/birkir%2Fgraphql-mst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birkir%2Fgraphql-mst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birkir%2Fgraphql-mst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/birkir%2Fgraphql-mst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/birkir","download_url":"https://codeload.github.com/birkir/graphql-mst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565086,"owners_count":21125415,"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":["converter","graphql","mobx","mobx-state-tree","mst","parser","typescript"],"created_at":"2024-07-31T07:01:26.531Z","updated_at":"2025-04-12T12:03:18.220Z","avatar_url":"https://github.com/birkir.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"[![npm downloads](https://img.shields.io/npm/dt/graphql-mst.svg)](https://www.npmjs.com/package/graphql-mst)\n[![npm](https://img.shields.io/npm/v/graphql-mst.svg?maxAge=2592000)](https://www.npmjs.com/package/graphql-mst)\n[![codecov](https://codecov.io/gh/birkir/graphql-mst/branch/master/graph/badge.svg)](https://codecov.io/gh/birkir/graphql-mst)\n[![CircleCI](https://circleci.com/gh/birkir/graphql-mst.svg?style=shield)](https://circleci.com/gh/birkir/graphql-mst)\n[![MIT license](https://img.shields.io/github/license/birkir/graphql-mst.svg)](https://opensource.org/licenses/MIT)\n\n# graphql-mst\n\nConvert GraphQL Schema to mobx-state-tree models.\n\nSee demos in [tests folder](https://github.com/birkir/graphql-mst/blob/master/__tests__/index.ts)\n\n### Installing\n\n```bash\nyarn add graphql-mst\n# or\nnpm install graphql-mst\n```\n\n### Usage\n\n```ts\nimport { generateFromSchema } from 'graphql-mst';\n\nconst schema = `\n  type Foo {\n    a: String\n    b: Int\n  }\n  type Bar {\n    c: [Foo]\n  }\n`;\n\nconst { Foo, Bar } = generateFromSchema(schema);\n\nconst foo = Foo.create({\n  a: 'Hello',\n  b: 10,\n});\n\nconst bar = Bar.create({\n  c: [foo, { a: 'World', b: 20 }],\n});\n```\n\n#### Identifiers\n\n```ts\nconst schema = `\n  type Foo {\n    userId: ID!\n    fooId: ID!\n  }\n`;\n\nconst config = {\n  Foo: {\n    identifier: 'fooId', // this will be used as identifier for model 'Foo'\n  },\n};\n\nconst { Foo } = generateFromSchema(schema, config);\n\nconst lookup = types\n  .model({ items: types.map(Foo) })\n  .actions(self =\u003e ({ add: item =\u003e self.items.put(item) }))\n  .create({ items: {} });\n\nlookup.put({ userId: 10, fooId: 1 });\nlookup.put({ userId: 20, fooId: 2 });\n\nlookup.items.get(1); // { userId: 10, fooId: 1 }\nlookup.items.get(2); // { userId: 20, fooId: 2 }\n```\n\n### TODO and thoughts\n\n- Configure map type instead of array type\n- Default values for arguments as `types.optional`\n- reference types?\n- Date scalar? Custom scalar?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirkir%2Fgraphql-mst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirkir%2Fgraphql-mst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirkir%2Fgraphql-mst/lists"}