{"id":16678487,"url":"https://github.com/2fd/graphtype","last_synced_at":"2025-10-19T00:50:26.172Z","repository":{"id":48310404,"uuid":"80136949","full_name":"2fd/graphtype","owner":"2fd","description":"Generate TypeScripts definitions from GraphQL","archived":false,"fork":false,"pushed_at":"2021-10-16T00:06:51.000Z","size":292,"stargazers_count":11,"open_issues_count":23,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T13:29:30.489Z","etag":null,"topics":[],"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/2fd.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}},"created_at":"2017-01-26T17:24:39.000Z","updated_at":"2022-01-31T01:11:38.000Z","dependencies_parsed_at":"2022-09-21T11:11:59.136Z","dependency_job_id":null,"html_url":"https://github.com/2fd/graphtype","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2fd%2Fgraphtype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2fd%2Fgraphtype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2fd%2Fgraphtype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2fd%2Fgraphtype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2fd","download_url":"https://codeload.github.com/2fd/graphtype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817526,"owners_count":16885555,"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-12T13:29:28.378Z","updated_at":"2025-10-19T00:50:26.060Z","avatar_url":"https://github.com/2fd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphtype\n\n[![Build Status](https://travis-ci.org/2fd/graphtype.svg?branch=master)](https://travis-ci.org/2fd/graphtype)\n\nGenerator of TypeScripts definitions for GraphQL\n\n## Install\n\n```bash\n    npm install -g @2fd/graphtype\n```\n\n## Use\n\n### Generate definitions from live endpoint\n\n```bash\n    \u003e graphtype -e http://localhost:8080/graphql -o ./doc/schema.d.ts\n```\n\n### Generate definitions from json file\n\n```bash\n    \u003e graphtype -s ./schema.json -o ./doc/schema.d.ts\n```\n\n\u003e `./schema.json` contains the result of [GraphQL introspection query](https://github.com/2fd/graphdoc/blob/gh-pages/introspection.graphql)\n\n\n### Add scalars that must be represented as numbers\n\n```bash\n    \u003e graphtype -e http://localhost:8080/graphql -n \"UnsignedInt\"\n```\n\n```typescript\n    /**\n     * Represents `true` or `false` values.\n     */\n    export type UnsignedInt = number;\n```\n\n### Add scalars that must be represented as numbers\n\n```bash\n    \u003e graphtype -e http://localhost:8080/graphql -n \"UnsignedInt\"\n```\n\n```typescript\n    // ...\n    export type UnsignedInt = number;\n    // ...\n```\n\n### Add scalars that must be represented as alias of other types\n\n```bash\n    \u003e graphtype -e http://localhost:8080/graphql -s \"NumberOrString=number | string\"\n```\n\n```typescript\n    // ...\n    export type NumberOrString = number | string;\n    // ...\n```\n\n### Help\n\n```bash\n\n    \u003e graphtype -h\n\n    Generator of TypeScripts definitions for GraphQL v1.0.0\n\n    Usage: graphtype [OPTIONS]\n\n     [OPTIONS]:\n    -e, --endpoint        Graphql http endpoint [\"https://domain.com/graphql\"].\n    -x, --header          HTTP header for request (use with --endpoint). [\"Authorization: Token cb8795e7\"].\n    -q, --query           HTTP querystring for request (use with --endpoint) [\"token=cb8795e7\"].\n    -s, --schema          Graphql Schema file [\"./schema.json\"].\n    -o, --output          Output file (otherwise write on stdout).\n    -n, --number-alias    Scalars that must be represented as numbers [\"UnsignedInt\"].\n    -a, --alias           Scalars that must be represented as alias of other types [\"NumberOrString=number | string\"].\n    -V, --version         Show graphtype version.\n    -h, --help            Print this help\n\n```\n\n## Translations\n\n### TypeScripts definitions (.d.ts)\n\n* [Scalars](#scalars)\n* [Enums](#enums)\n* [Unions](#unions)\n* [Interfaces](#interfaces)\n* [Types](#types)\n* [Inputs](#inputs)\n\n\n#### Scalars\n\n```graphql\n    # schema definitions\n\n    scalar Boolean;\n    scalar Int;\n    scalar String;\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * Represents `true` or `false` values.\n     */\n    export type Boolean = boolean;\n\n    /**\n     * Represents non-fractional signed whole numeric values. Int can represent values\n     * between -(2^31) and 2^31 - 1.\n     */\n    export type Int = number;\n\n    /**\n     * Represents textual data as UTF-8 character sequences. This type is most often\n     * used by GraphQL to represent free-form human-readable text.\n     */\n    export type String = string;\n```\n\n![Autocomplete Scalars on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.scalar.png)\n\n#### Enums\n\n```graphql\n    # schema definitions\n\n    enum __TypeKind {\n        SCALAR\n        OBJECT\n        INTERFACE\n        UNION\n        ENUM\n        INPUT_OBJECT\n        LIST\n        NON_NULL\n    }\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * An enum describing what kind of type a given `__Type` is.\n     */\n    export type __TypeKind = (\n\n        /**\n         * Indicates this type is a scalar.\n         */\n        \"SCALAR\" |\n\n        /**\n         * Indicates this type is an object. `fields` and `interfaces` are valid fields.\n         */\n        \"OBJECT\" |\n\n        /**\n         * Indicates this type is an interface. `fields` and `possibleTypes` are valid\n         * fields.\n         */\n        \"INTERFACE\" |\n\n        /**\n         * Indicates this type is a union. `possibleTypes` is a valid field.\n         */\n        \"UNION\" |\n\n        /**\n         * Indicates this type is an enum. `enumValues` is a valid field.\n         */\n        \"ENUM\" |\n\n        /**\n         * Indicates this type is an input object. `inputFields` is a valid field.\n         */\n        \"INPUT_OBJECT\" |\n\n        /**\n         * Indicates this type is a list. `ofType` is a valid field.\n         */\n        \"LIST\" |\n\n        /**\n         * Indicates this type is a non-null. `ofType` is a valid field.\n         */\n        \"NON_NULL\"\n    );\n```\n\n![Autocomplete Enums on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.enum.png)\n\n#### Unions\n\n```graphql\n    # schema definitions\n\n    union ProjectCardItem = Issue | PullRequest;\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * Types that can be inside Project Cards.\n     */\n    export type ProjectCardItem = Issue | PullRequest;\n```\n\n![Autocomplete Enums on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.union.png)\n\n#### Interfaces\n\n```graphql\n    # schema definitions\n\n    interface Node {\n        id: ID!\n    }\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * An application user.\n     */\n    export interface Node {\n\n        /**\n         * .ID of the node.\n         */\n        id: NonNull\u003cID\u003e;\n    }\n```\n\n![Autocomplete Enums on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.interface.png)\n\n#### Types\n\n```graphql\n    # schema definitions\n\n    type User implements Node {\n        id: ID!\n        email: String!\n        name: String\n        lastName: String\n        friends: [ID!]!\n    }\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * An application user.\n     */\n    export interface User extends Node {\n\n        /**\n         * ID of the user.\n         */\n        id: NonNull\u003cID\u003e;\n\n        /**\n         * contact email of the user.\n         */\n        email: NonNull\u003cString\u003e;\n\n        /**\n         * name of the user.\n         */\n        name?: Optional\u003cString\u003e;\n\n        /**\n         * last name of the user.\n         */\n        lastName?: Optional\u003cString\u003e;\n\n        /**\n         * list of friend´s ID of the user.\n         */\n        friends: NonNull\u003cList\u003cNonNull\u003cID\u003e\u003e\u003e;\n    }\n```\n\n![Autocomplete Objects on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.type.png)\n\n#### Inputs\n\n```graphql\n    # schema definitions\n\n    input NewUser {\n        email: String!\n        name: String\n        lastName: String\n        friends: [ID!] = []\n    }\n```\n\n```typescript\n    // typescript output\n\n    /**\n     * An application user.\n     */\n    export interface NewUser {\n\n        /**\n         * contact email of the user.\n         */\n        email: NonNull\u003cString\u003e;\n\n        /**\n         * name of the user.\n         */\n        name?: Optional\u003cString\u003e;\n\n        /**\n         * last name of the user.\n         */\n        lastName?: Optional\u003cString\u003e;\n\n        /**\n         * @default []\n         *\n         * list of friend´s ID of the user.\n         */\n        friends?: Optional\u003cList\u003cNonNull\u003cID\u003e\u003e\u003e;\n    }\n```\n\n![Autocomplete Inputs on Typescript](https://github.com/2fd/graphtype/raw/master/img/typescript.input.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2fd%2Fgraphtype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2fd%2Fgraphtype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2fd%2Fgraphtype/lists"}