{"id":19882940,"url":"https://github.com/svengau/apollo-link-directive","last_synced_at":"2025-05-02T14:32:53.786Z","repository":{"id":35155508,"uuid":"214042523","full_name":"svengau/apollo-link-directive","owner":"svengau","description":"An Apollo Link to easily add custom directives in your GraphQL queries.","archived":false,"fork":false,"pushed_at":"2025-04-24T23:57:06.000Z","size":31,"stargazers_count":7,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T00:34:58.778Z","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/svengau.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":"2019-10-09T23:20:08.000Z","updated_at":"2024-04-21T07:46:24.000Z","dependencies_parsed_at":"2024-03-20T15:43:58.096Z","dependency_job_id":"c6892653-8680-4adb-b8dd-8d390d53c550","html_url":"https://github.com/svengau/apollo-link-directive","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":0.09090909090909094,"last_synced_commit":"ee1382cb16973ea9a03dcc7611cf31562bf8e36a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svengau%2Fapollo-link-directive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svengau%2Fapollo-link-directive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svengau%2Fapollo-link-directive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svengau%2Fapollo-link-directive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svengau","download_url":"https://codeload.github.com/svengau/apollo-link-directive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250735332,"owners_count":21478606,"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-11-12T17:18:59.705Z","updated_at":"2025-05-02T14:32:53.532Z","avatar_url":"https://github.com/svengau.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo Directive Link\n\n[![Build Status](https://travis-ci.org/svengau/apollo-link-directive.svg?branch=master)](https://travis-ci.org/svengau/apollo-link-directive)\n\n## Purpose\n\nAn Apollo Link to easily add custom directives in your GraphQL queries.\n\n## Installation\n\n```bash\n\nnpm install apollo-link-directive --save\n# or\nyarn add apollo-link-directive\n\n```\n\n## Usage\n\n### Basics\n\nThis sample code shows how to use this Apollo Link to change the HttpLink uri with the \"admin\" directive: \n\n```js\n\nimport { from } from 'apollo-link';\nimport { HttpLink } from 'apollo-link-http';\nimport { DirectiveLink } from \"apollo-link-directive\";\n\nconst adminDirectiveLink = new DirectiveLink([\n  { \n    directive: 'admin', \n    callback: (operation, _forward) =\u003e operation.setContext({ uri: '/graphql-admin' })\n   },\n]);\n\nconst httpLink = new HttpLink({\n  uri: '/graphql',\n});\n\n// Configure the ApolloClient\nconst client = new ApolloClient({\n  link: from([adminDirectiveLink,  httpLink]),\n  cache: new InMemoryCache(),\n});\n\n\n\n```\n\nthis sample code will update all queries having admin directive with uri: /graphql-admin, for example from this query:\n\n```\n\nconst query = gql`\n  query luke {\n    person @admin {\n      name\n    }\n  }\n`;\n\n```\n\n## Options\n\nThe options you can pass to DirectiveLink are an array of directives like this:\n\n- `directive`: the name of the directive\n- `callback`: a callback function with args `operation` and `forward`\n- `remove`: an option to remove the directive from the code. Default: true\n\n## Thanks\n\nSetting up the project has been largely inspired by the wonderful [apollo-link-rest](https://github.com/apollographql/apollo-link-rest) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvengau%2Fapollo-link-directive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvengau%2Fapollo-link-directive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvengau%2Fapollo-link-directive/lists"}