{"id":15541910,"url":"https://github.com/snewcomer/ember-data-jsonapi-fields","last_synced_at":"2025-04-04T17:23:47.256Z","repository":{"id":89488281,"uuid":"287770881","full_name":"snewcomer/ember-data-jsonapi-fields","owner":"snewcomer","description":"Querying for jsonapi fields through @ember/data JSONAPIAdapter","archived":false,"fork":false,"pushed_at":"2020-08-16T20:03:30.000Z","size":170,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T08:23:58.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/snewcomer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2020-08-15T15:14:35.000Z","updated_at":"2022-03-26T03:43:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab3cb408-2c9a-484a-8568-592c264d89da","html_url":"https://github.com/snewcomer/ember-data-jsonapi-fields","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/snewcomer%2Fember-data-jsonapi-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-data-jsonapi-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-data-jsonapi-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-data-jsonapi-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snewcomer","download_url":"https://codeload.github.com/snewcomer/ember-data-jsonapi-fields/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247218150,"owners_count":20903205,"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":"2024-10-02T12:20:01.000Z","updated_at":"2025-04-04T17:23:47.227Z","avatar_url":"https://github.com/snewcomer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ember-data-jsonapi-fields\n==============================================================================\n\nCurrently, [@ember/data](https://github.com/emberjs/data) does not handle support for JSONAPI [fields](https://jsonapi.org/format/#document-resource-object-fields).  [`fields`](https://jsonapi.org/format/#fetching-sparse-fieldsets) allows you to serve a minimal payload, saving time on the wire. This will change in the future.  However, the current system does not allow for a robust, drop in replacement for everyone.  In the meantime, this addon exists!\n\n\nCompatibility\n------------------------------------------------------------------------------\n\n* Ember.js v3.8 or above\n* Ember CLI v2.13 or above\n* Node.js v8 or above\n\n\nInstallation\n------------------------------------------------------------------------------\n\n```\nember install ember-data-jsonapi-fields\n```\n\n\nYou want to use this\n------------------------------------------------------------------------------\n\n```js\nimport { JSONAPIFieldsAdapter } from 'ember-data-jsonapi-fields';\n\nexport default class MyJSONAPIAdapter extends JSONAPIFieldsAdapter {\n  ...\n}\n```\n```js\nstore.findRecord('post', 123, {\n  adapterOptions: { fields: { post: 'name,body' } }\n});\n\n// Note: @ember/data already includes support for `includes`.\nstore.findRecord('post', 123, {\n  adapterOptions: { fields: { post: 'name,body', comments: 'title' } }, include: 'comments'\n});\n```\n\nYou may not want to use this\n------------------------------------------------------------------------------\n\nYou may not want to install this addon for a variety of reasons.  One might be your visceral reaction to installing yet another library.\n\nThere is one case you might want to roll your own implementation.  If you don't care about caching mechanisms, simply override `buildQuery`.\n\n```js\nimport JSONAPIAdapter from '@ember-data/adapter/json-api';\n\nexport default ApplicationAdapter extends JSONAPIAdapter {\n  buildQuery(snapshot) {\n    let query = this._super(...arguments);\n\n    if (snapshot.adapterOptions) {\n      let { fields } = snapshot.adapterOptions;\n\n      if (fields) {\n        query.fields = fields;\n      }\n    }\n\n    return query;\n  },\n}\n```\n\nContributing\n------------------------------------------------------------------------------\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n\nLicense\n------------------------------------------------------------------------------\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnewcomer%2Fember-data-jsonapi-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnewcomer%2Fember-data-jsonapi-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnewcomer%2Fember-data-jsonapi-fields/lists"}