{"id":15015859,"url":"https://github.com/nlepage/ember-use-graphql","last_synced_at":"2026-02-18T15:01:48.820Z","repository":{"id":229180106,"uuid":"776019161","full_name":"nlepage/ember-use-graphql","owner":"nlepage","description":"Modern Ember GraphQL integration.","archived":false,"fork":false,"pushed_at":"2024-05-07T12:45:11.000Z","size":436,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T06:28:03.090Z","etag":null,"topics":["apollo-client","ember-addon","emberjs","graphql"],"latest_commit_sha":null,"homepage":"","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/nlepage.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":"2024-03-22T14:13:24.000Z","updated_at":"2024-07-10T22:59:14.000Z","dependencies_parsed_at":"2024-05-06T20:30:37.328Z","dependency_job_id":"eda24b18-f7d6-44d3-b16d-fc0495384ad1","html_url":"https://github.com/nlepage/ember-use-graphql","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"0a89e27cbcb47886b2d7b6725cd58fd4746fc155"},"previous_names":["nlepage/ember-use-graphql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlepage%2Fember-use-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlepage%2Fember-use-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlepage%2Fember-use-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlepage%2Fember-use-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlepage","download_url":"https://codeload.github.com/nlepage/ember-use-graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239568073,"owners_count":19660610,"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":["apollo-client","ember-addon","emberjs","graphql"],"created_at":"2024-09-24T19:48:03.758Z","updated_at":"2025-10-11T21:01:42.149Z","avatar_url":"https://github.com/nlepage.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-use-graphql\n\nModern Ember GraphQL integration, TypeScript and [GraphQL-Codegen](https://the-guild.dev/graphql/codegen) friendly.\n\n## Installation\n\nUsing npm:\n\n```\nnpm install -D ember-use-graphql graphql @apollo/client graphql-tag\n```\n\nUsing yarn:\n\n```\nyarn add -D ember-use-graphql graphql @apollo/client graphql-tag\n```\n\nUsing pnpm:\n\n```\npnpm add -D ember-use-graphql graphql @apollo/client graphql-tag\n```\n\n## Usage\n\n### Provide the Apollo client\n\nIn order to provide an Apollo client to be used by ember-use-graphql, create an [application initializer](https://guides.emberjs.com/release/applications/initializers/#toc_application-initializers) in your `app/initializers` directory:\n\n```js\n// app/initializers/apollo.js\n\nimport { ApolloClient, InMemoryCache } from '@apollo/client/core';\n\nexport function initialize(application) {\n  const client = new ApolloClient({\n    cache: new InMemoryCache(),\n    uri: 'https://example.com/graphql',\n  });\n\n  application.register('apollo:default', client, { instantiate: false });\n}\n\nexport default {\n  name: 'apollo',\n  initialize,\n};\n```\n\nIn this example the Apollo client is registered under the name `apollo:default`, and will then be the default client for performing GraphQL operations, [unless specified otherwise](#use-several-apollo-clients).\n\n### Queries\n\nQueries can be performed in Components or Routes' models using ember-use-graphql's `useQuery` function.\n\nThe results returned by `useQuery` are reactive, and will keep up to date with Apollo client's cache.\n\nember-use-graphql manages the lifecycle of queries by listening to the Component/Route's events, DO NOT call `useQuery` in Controllers or outside of the Route's model method.\n\n#### Component queries\n\nREADME\n\n## Advanced usage\n\n### Use several Apollo clients\n\nIf your application needs to use several Apollo clients, you will need to register these under different names in the application initializer:\n\n```js\n// app/initializers/apollo.js\n\nimport { ApolloClient, InMemoryCache } from '@apollo/client/core';\n\nexport function initialize(application) {\n  const defaultClient = new ApolloClient({\n    cache: new InMemoryCache(),\n    uri: 'https://api.example.com/graphql',\n  });\n\n  application.register('apollo:default', defaultClient, { instantiate: false });\n\n  const alternateClient = new ApolloClient({\n    cache: new InMemoryCache(),\n    uri: 'https://private-api.example.com/graphql',\n  });\n\n  application.register('apollo:alternate', alternateClient, { instantiate: false });\n}\n\nexport default {\n  name: 'apollo',\n  initialize,\n};\n```\n\nThen you must specify which client should be used when querying:\n\n```js\n// app/components/example.js\n\nexport default class ExampleComponent extends Component {\n  // no client specified, will use defaultClient\n  firstQuery = useQuery(this, gql`...`, {\n    variables: {\n      // ...\n    },\n  });\n\n  // will use alternateClient\n  secondQuery = useQuery(this, gql`...`, {\n    client: 'alternate',\n    variables: {\n      // ...\n    },\n  });\n}\n```\n\n## Common problems\n\n### ts(2742): The inferred type of 'x' cannot be named without a reference to '@apollo/client/core'\n\nThis error might occur when using pnpm, the `node_modules` layout generated by pnpm messes Typescript's type inference.\n\nTo workaround this error, add the following line in the `types/global.d.ts` file of your Ember app:\n\n```ts\nimport '@apollo/client/core';\n```\n\n## Compatibility\n\n- Ember.js v4.12 or above\n- Embroider or ember-auto-import v2\n\n## Contributing\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlepage%2Fember-use-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlepage%2Fember-use-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlepage%2Fember-use-graphql/lists"}