{"id":49453656,"url":"https://github.com/theGlenn/apollo-prophecy","last_synced_at":"2026-06-02T05:00:44.257Z","repository":{"id":32556703,"uuid":"135944735","full_name":"theGlenn/apollo-prophecy","owner":"theGlenn","description":"🔮 GraphQL error management made Easy, generate custom machine-readable errors for Apollo Client/Server from the CLI","archived":false,"fork":false,"pushed_at":"2023-01-06T15:40:12.000Z","size":858,"stargazers_count":86,"open_issues_count":25,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-23T10:50:21.040Z","etag":null,"topics":["apollo","apollo-codegen","apollographql","code-generation","error-handling","graphql","graphql-tools","typescript"],"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/theGlenn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-03T22:13:08.000Z","updated_at":"2024-05-29T04:39:40.000Z","dependencies_parsed_at":"2023-01-14T21:35:07.875Z","dependency_job_id":null,"html_url":"https://github.com/theGlenn/apollo-prophecy","commit_stats":null,"previous_names":["theglenn/apollo-pythian"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/theGlenn/apollo-prophecy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fapollo-prophecy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fapollo-prophecy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fapollo-prophecy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fapollo-prophecy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theGlenn","download_url":"https://codeload.github.com/theGlenn/apollo-prophecy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fapollo-prophecy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33806987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","apollo-codegen","apollographql","code-generation","error-handling","graphql","graphql-tools","typescript"],"created_at":"2026-04-30T04:01:03.702Z","updated_at":"2026-06-02T05:00:44.251Z","avatar_url":"https://github.com/theGlenn.png","language":"TypeScript","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://imgur.com/AuFdzQQ.png\" width=\"100\" /\u003e\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eApollo Prophecy\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n👁📟👁\n\u003cbr/\u003e\u003cstrong\u003eYou shall fail... successfully\u003c/strong\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  Command tool to generate errors files for your Appolo Server and Client \n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- NPM version --\u003e\n  \u003ca href=\"https://npmjs.org/package/apollo-prophecy\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/apollo-prophecy.svg\"\n      alt=\"NPM version\" /\u003e\n  \u003c/a\u003e\n  \n  \u003c!-- Build Status --\u003e\n  \u003ca href=\"https://travis-ci.com/theGlenn/apollo-prophecy\"\u003e\n    \u003cimg src=\"https://travis-ci.com/theGlenn/apollo-prophecy.svg?branch=master\"\n      alt=\"Build Status\" /\u003e\n  \u003c/a\u003e\n\n  \u003c!-- Coverage Status --\u003e\n  \u003ca href=\"https://coveralls.io/github/theGlenn/apollo-prophecy?branch=master\"\u003e\n    \u003cimg src=\"https://coveralls.io/repos/github/theGlenn/apollo-prophecy/badge.svg?branch=master\"\n      alt=\"Coverage Status\" /\u003e\n  \u003c/a\u003e\n\n  \u003c!-- License --\u003e\n  \u003ca href=\"https://github.com/theGlenn/apollo-prophecy/blob/develop/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\n      alt=\"License\" /\u003e\n  \u003c/a\u003e\n\n  \u003c!-- Contribute --\u003e\n  \u003ca href=\"https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/contributions-friendly-b44ac1.svg\"\n      alt=\"Contribute\" /\u003e\n  \u003c/a\u003e\n\n  \u003c!-- GitHub good first issue --\u003e\n  \u003ca href=\"https://github.com/theGlenn/apollo-prophecy/labels/good%20first%20issue\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/theGlenn/apollo-prophecy/good%20first%20issue.svg\"\n      alt=\"GitHub good first issue\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://twitter.com/intent/follow?screen_name=glennsonna\"\u003e\n    \u003cimg src=\"https://img.shields.io/twitter/follow/glennsonna.svg?style=social\u0026logo=twitter\" alt=\"follow on Twitter\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## 📟 Features\n\n* Generate **Server-side** **throwable** errors in your resolvers like `throw new NotAProphetError()`\n* Expose **machine readable** graphql errors through your api documentation\n* Generate **Client-side** Apollo errors **consumable** like `errorHere(error).isNotAProphetError ?`\n\n# 📋 Table of Contents\n\n  * [Installation](#installation)\n  * [Usage](#usage)\n    * [Server Side](#server)\n    * [Client Side](#client)\n  * [Contributing](#contributing)\n    * [TODO](#todo)\n    * [Test and Miscellaneous](#run-tests)\n\n## Installation\n\nInstall with npm:\n\n```sh\nnpm install -g apollo-prophecy\n```\n\nInstall with yarn:\n\n```sh\nyarn global add apollo-prophecy\n```\n\n## Usage\n\n```\nUsage: apollo-prophecy [command]\n\nCommands:\n  apollo-prophecy generate \u003cjson file\u003e [--out]\n  apollo-prophecy ask \u003cgraphql endpoint\u003e [--type] [--out]\n\nOptions:\n  -h, --help     Show help                                             [boolean]\n  -v, --version  Display version number                                [boolean]\n```\n\n### Server\n\u003e ⚠️ This Project is *Only* compatible with Apollo-Server v2\n\n#### `generate` command\n\nCreates `Error.ts` from a `JSON` input file. Using `--out` param you can change the name and location.\n\n```sh\napollo-prophecy generate errors.json\n```\n\nInput file entries should at least contains the keys `message` and `code`.\n\nFor example given the following `errors.json` as input:\n\n```json\n{\n  \"AuthenticationRequiredError\": {\n    \"message\": \"You must be logged in to do this\",\n    \"code\": \"AUTH_REQUIRED\"\n  },\n  \"UserNotFoundError\": {\n    \"message\": \"No user found\",\n    \"code\": \"USER_NOT_FOUND\"\n  },\n}\n```\n\nApollo Prophecy will generate the following `Errors.ts`\n\n```ts\n...\nexport class AuthenticationRequiredError extends ProphecyError {\n  constructor(properties?: Record\u003cstring, any\u003e) {\n    super(\"AuthenticationRequiredError\", \"You must be logged in to do this\",\"AUTH_REQUIRED\", properties);\n  }\n}\n  \nexport class UserNotFoundError extends ProphecyError {\n  constructor(properties?: Record\u003cstring, any\u003e) {\n    super(\"UserNotFoundError\", \"No user found\", \"USER_NOT_FOUND\", properties);\n  }\n}\n...\n```\n\nNow you can use it the following way `throw new UserNotFoundError()` in your resolvers.\n\n`apollo-prophecy` also exposes a `definitions` object and a graphql type definition named `PropheticError` so that you can expose all your errors descriptions through a resolver, [see Client](###client).\n\n```ts\n...\nexport const definitions = [{\n    \"name\": \"AuthenticationRequiredError\"\n    \"message\": \"You must be logged in to do this\",\n    \"extensions\": {\n      \"code\": \"AUTH_REQUIRED\"\n    }\n  }, {\n    \"name\": \"UserNotFoundError\"\n    \"message\": \"No user found\",\n    \"extensions\": {\n      \"code\": \"USER_NOT_FOUND\"\n    }\n  }\n}];\n\nexport const errorType = `\n  type PropheticErrorExtensions {\n    code: String\n  }\n\n  type PropheticError {\n    message: String?\n    extensions: PropheticErrorExtensions\n  }\n`;\n...\n```\n\n### Client\n\n#### `ask` command\n\nQueries the `errors` field on the specified graphql endpoint and creates an `Errors.ts` file containing helpers with **check methods** ([see Helpers](#helpers)) for all the errors exposed through the server api documentation.\n\n```sh\napollo-prophecy ask http://localhost:3000/graphql\n```\n\n#### Helpers\n\nIn order to easily handle erros with **Apollo-Client**, the generated `Errors.ts` exposes two helpers methods `errorHere` and `isThis`, both methods takes one paramater of type `ApolloError` or `GraphQLError`.\n\n##### `errorHere()` function\n\n`errorHere` returns an object that has a **property** named after each errors.\nYou can perform a simple `boolean` check on the `error` argument by calling the approiate *key*.\n\n```ts\nimport { errorHere } from `./_generated/Errors.ts`;\n\n...(error) =\u003e {\n  if(errorHere(error).isUserNotFoundError){\n    // Do something\n  } else if(errorHere(error).isNotAProphetError){\n    // Do something else\n  }\n}\n```\n\n##### `isThis()` function\n\n`isThis` returns an object that has a **handler** method for each errors.\nIt perfoms a simple check on the `error` argument, if the it succeed the corresponding handler is called otherwise nothing happens.\n\nNote: Handlers can return a values.\n\n```ts\nimport { isThis } from `./_generated/Errors.ts`;\n\n...(error) =\u003e {\n  isThis(error)\n  .UserNotFoundError(() =\u003e ...)\n  .NotAProphetError(() =\u003e ...)\n  .handle()\n}\n```\n\nReact example:\n\n```tsx\nimport { isThis } from `./_generated/Errors.ts`;\n\n...(error) =\u003e {\n  return \u003cp style={{color: '#FF495C'}}\u003e\n    {\n      isThis(error)\n      .UserNotFoundError(() =\u003e \u003cspan\u003eCould not find a user with tha name\u003c/span\u003e)\n      .NotAProphetError(() =\u003e \u003cspan\u003eOnly Prophets can perfom this kind of actions...\u003c/span\u003e)\n      .handle();\n    }\n  \u003c/p\u003e\n}\n```\n\n## Contributing \n[![Build status](https://travis-ci.com/theGlenn/apollo-prophecy.svg?branch=master\u0026style=flat-square)](https://travis-ci.com/theGlenn/apollo-prophecy)\n\n\u003cdiv\u003e\n  \u003ctable \u003e\n    \u003ctr\u003e\u003ctd\u003e✊\u003c/td\u003e\u003ctd align=\"center\"\u003eGrab an issue\u003c/td\u003e \u003ctd\u003e⏬\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e🍴\u003c/td\u003e\u003ctd align=\"center\"\u003efork \u003cstrong\u003edevelop\u003c/strong\u003e\u003c/td\u003e \u003ctd\u003e⏬\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e👨‍💻\u003c/td\u003e\u003ctd align=\"center\"\u003eCode\u003c/td\u003e \u003ctd\u003e⏬\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e🛠\u003c/td\u003e\u003ctd align=\"center\"\u003eTest\u003c/td\u003e \u003ctd\u003e⏬\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e📩\u003c/td\u003e\u003ctd align=\"center\"\u003ePull Request\u003c/td\u003e \u003ctd\u003e⏬\u003c/td\u003e\u003c/tr\u003e\n  \u003c/table\u003e\n  \u003cp\u003e💥💥💥\u003c/p\u003e\n\u003c/div\u003e\n\n### TODO\n\n* See [#2][i2]: Add support for third-party errors libraries like [apollo-errors](https://github.com/thebigredgeek/apollo-errors) \u003ca class=\"d-inline-block IssueLabel v-align-text-top labelstyle-7057ff linked-labelstyle-7057ff tooltipped tooltipped-s\" style=\"background-color: #7057ff; color: #ffffff\"\u003egood first issue\u003c/a\u003e\n* See [#12][i12]: Add `errors.json` file as ask command argument \u003ca class=\"d-inline-block IssueLabel v-align-text-top labelstyle-7057ff linked-labelstyle-7057ff tooltipped tooltipped-s\" style=\"background-color: #7057ff; color: #ffffff\"\u003egood first issue\u003c/a\u003e\n* See [#16][i16]: Add language specific code generation [Java/Kotlin][i13]/[Swift][i14]/[Javascript][i15]\n  * See [#13][i13]: Java/Kotlin  \u003ca class=\"d-inline-block IssueLabel v-align-text-top labelstyle-7057ff linked-labelstyle-7057ff tooltipped tooltipped-s\" style=\"background-color: #7057ff; color: #ffffff\"\u003egood first issue\u003c/a\u003e\n  * See [#14][i14]: Swift \u003ca class=\"d-inline-block IssueLabel v-align-text-top labelstyle-7057ff linked-labelstyle-7057ff tooltipped tooltipped-s\" style=\"background-color: #7057ff; color: #ffffff\"\u003egood first issue\u003c/a\u003e\n  * See [#15][i15]: Javascript \u003ca class=\"d-inline-block IssueLabel v-align-text-top labelstyle-7057ff linked-labelstyle-7057ff tooltipped tooltipped-s\" style=\"background-color: #7057ff; color: #ffffff\"\u003egood first issue\u003c/a\u003e\n\n\n[i2]: https://github.com/theGlenn/apollo-prophecy/issues/2\n[i12]: https://github.com/theGlenn/apollo-prophecy/issues/12\n\n[i13]: https://github.com/theGlenn/apollo-prophecy/issues/13\n[i14]: https://github.com/theGlenn/apollo-prophecy/issues/14\n[i15]: https://github.com/theGlenn/apollo-prophecy/issues/15\n\n[i16]: https://github.com/theGlenn/apollo-prophecy/issues/16\n\n### Run tests\n\n```sh\nnpm test\n```\n\n```sh\nyarn test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheGlenn%2Fapollo-prophecy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FtheGlenn%2Fapollo-prophecy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheGlenn%2Fapollo-prophecy/lists"}