{"id":26070251,"url":"https://github.com/rintoj/gql-assist","last_synced_at":"2025-03-08T23:07:45.396Z","repository":{"id":278728028,"uuid":"809871674","full_name":"rintoj/gql-assist","owner":"rintoj","description":"GQL Assist is your go-to tool for supercharging GraphQL development. It simplifies writing GraphQL queries for Apollo Client by converting them into TypeScript code, making your development process smoother and error-free.","archived":false,"fork":false,"pushed_at":"2025-02-21T10:35:58.000Z","size":402,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T11:32:12.518Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rintoj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-03T15:55:53.000Z","updated_at":"2025-02-21T10:35:13.000Z","dependencies_parsed_at":"2025-02-21T11:43:54.362Z","dependency_job_id":null,"html_url":"https://github.com/rintoj/gql-assist","commit_stats":null,"previous_names":["rintoj/gql-assist"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fgql-assist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fgql-assist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fgql-assist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fgql-assist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rintoj","download_url":"https://codeload.github.com/rintoj/gql-assist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242619124,"owners_count":20159003,"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":"2025-03-08T23:07:44.233Z","updated_at":"2025-03-08T23:07:45.371Z","avatar_url":"https://github.com/rintoj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GQL Assist\n\nGQL Assist is your go-to tool for supercharging GraphQL development. It simplifies writing GraphQL\nqueries for Apollo Client by converting them into TypeScript code, making your development process\nsmoother and error-free. On the server side, gql-assist streamlines API development in NestJS by\nautomatically converting TypeScript classes, resolvers, and enums into their GraphQL counterparts,\ndrastically reducing boilerplate code. With gql-assist, you can focus on building your application\nwhile it handles the heavy lifting of GraphQL integration.\n\n## Installation\n\nTo install GQL Assist, use npm or yarn:\n\n```bash\nnpm install gql-assist\n```\n\nor\n\n```bash\nyarn add gql-assist\n```\n\n## Features\n\nDiscover the power of GraphQL Assist with its suite of robust functionalities:\n\n### React Hook\n\nTransform your GraphQL queries into TypeScript code seamlessly compatible with\n[`@apollo/client`](https://www.apollographql.com/docs/react/). With GraphQL Assist, writing GraphQL\nqueries for Apollo Client becomes a breeze, letting you concentrate on what matters most—building\nyour application.\n\n### Server Side\n\nStreamline your GraphQL API development in a [NestJS](https://docs.nestjs.com/graphql/quick-start)\nenvironment with GraphQL Assist. Automatically convert TypeScript classes, resolvers, and enums into\ntheir GraphQL definitions, slashing boilerplate code and boosting productivity.\n\n- **Model Conversion**: Instantly convert TypeScript classes to NestJS GraphQL Object Types for\n  generating models, inputs, and response types.\n- **Resolver Conversion**: Effortlessly transform resolver methods into GraphQL resolvers with the\n  correct decorators.\n- **Field Resolver Conversion**: Easily convert methods to GraphQL field resolvers with the\n  necessary decorators.\n- **Enum Conversion**: Swiftly transform TypeScript enums to GraphQL enums and register them.\n\n## Usage\n\n```sh\nnpx gql-assist generate decorator\n```\n\n### React Hook\n\nGraphQL Assist can also help you with writing queries for graphql client by converting GraphQL\nqueries into TypeScript code compatible with `@apollo/client`. With GraphQL Assist, writing GraphQL\nqueries for Apollo Client becomes easier and less error-prone, allowing you to focus more on\nbuilding your application.\n\n```sh\nnpx gql-assist generate hook\n```\n\n#### Example\n\nGiven the following GraphQL query:\n\n```ts\nimport gql from 'graphql-tag'\n\nconst query = gql`\n  query {\n    user {\n      name\n    }\n  }\n```\n\nGraphQL Assist will look at the schema and convert it to the following on save:\n\n```ts\nimport { QueryHookOptions, useQuery } from '@apollo/client'\nimport gql from 'graphql-tag'\n\nconst query = gql`\n  query fetchUser($id: ID!) {\n    user(id: $id) {\n      name\n    }\n  }\n`\n\nexport interface RequestType {\n  id: string | undefined\n}\n\nexport interface QueryType {\n  user?: UserType\n}\n\nexport interface UserType {\n  name?: string\n  __typename?: 'User'\n}\n\nexport function useUserQuery(\n  request: RequestType,\n  options?: QueryHookOptions\u003cQueryType, RequestType\u003e,\n) {\n  return useQuery\u003cQueryType, RequestType\u003e(query, {\n    variables: request,\n    skip: !request.id,\n    ...options,\n  })\n}\n```\n\n### Models\n\nFor GQL Assist to recognize and convert a TypeScript class into a GraphQL ObjectType, it should be\nplaced in a file with the extension `.model.ts`.\n\n#### Example\n\nGiven the following TypeScript class:\n\n```ts\nexport class User {\n  id!: string\n  name?: string\n  email?: string\n  bio?: string\n  role?: UserRole\n}\n```\n\nGQL Assist will convert it to:\n\n```ts\nimport { Field, ID, ObjectType } from '@nestjs/graphql'\n\n@ObjectType()\nexport class User {\n  @Field(() =\u003e ID)\n  id!: string\n\n  @Field({ nullable: true })\n  name?: string\n\n  @Field({ nullable: true })\n  email?: string\n\n  @Field({ nullable: true })\n  bio?: string\n\n  @Field(() =\u003e UserRole, { nullable: true })\n  role?: UserRole\n}\n```\n\n#### Handling Internal Fields\n\nIn some cases, you may want to keep certain fields hidden from your GraphQL schema while still\nmaking them available for internal use within your application. For example, you might have a field\nthat is used internally for logic or data storage but should not be exposed to clients consuming the\nGraphQL API.\n\nTo achieve this, you can use the @InternalField() decorator as shown below:\n\n```ts\nimport { Field, ID, ObjectType } from '@nestjs/graphql'\n\n// Define the User class\nexport class User {\n  // This field is part of the GraphQL schema\n  id!: string\n\n  // Optional field exposed in the schema\n  name?: string\n\n  // Internal-only field, not exposed in the schema\n  @InternalField()\n  providerUid?: string\n}\n```\n\n- @InternalField() marks a field to be excluded from the generated GraphQL schema.\n- The providerUid field in the above example is available for backend operations but will not appear\n  in the GraphQL API exposed to clients.\n\nUse Cases\n\n1. Sensitive Data: Fields that contain sensitive data such as internal identifiers or tokens.\n2. System-Level Fields: Metadata or technical fields used only for internal processes.\n3. Data Transformation: Fields required for internal computations that should not be exposed\n   directly.\n\nBy using this pattern, you maintain a clean and secure schema while ensuring flexibility for backend\noperations.\n\n### Resolvers\n\nFor GQL Assist to recognize and convert a resolver method, it should be placed in a file with the\nextension `.resolver.ts`.\n\n#### Example\n\nGiven the following TypeScript class:\n\n```ts\nexport class UserResolver {\n  user(id: string, context: GQLContext) {\n    return null\n  }\n}\n```\n\nGQL Assist will convert it to:\n\n```ts\nimport { Args, Context, ID, Query, Resolver } from '@nestjs/graphql'\n\n@Resolver()\nexport class UserResolver {\n  @Query()\n  user(\n    @Args({ name: 'id', type: () =\u003e ID })\n    id: string,\n\n    @Context()\n    context: GQLContext,\n  ) {\n    return null\n  }\n}\n```\n\n### Field Resolvers\n\nFor GQL Assist to recognize and convert a field resolver method, it should be placed in a file with\nthe extension `.resolver.ts`.\n\n#### Example\n\nGiven the following TypeScript class:\n\n```ts\n@Resolver(() =\u003e User)\nexport class UserResolver {\n  fullName(parent: UserType) {}\n}\n```\n\nGQL Assist will convert it to:\n\n```ts\nimport { Parent, ResolveField, Resolver } from '@nestjs/graphql'\n\n@Resolver(() =\u003e User)\nexport class UserResolver implements FieldResolver\u003cUser, UserType\u003e {\n  @ResolveField()\n  fullName(\n    @Parent()\n    parent: UserType,\n  ) {}\n}\n```\n\n### Enums\n\nFor GQL Assist to recognize and convert enums, they should be placed in a file with the extension\n`.enum.ts`.\n\n#### Example\n\nGiven the following TypeScript enum:\n\n```ts\nexport enum UserStatus {\n  ACTIVE,\n  INACTIVE,\n}\n```\n\nGQL Assist will convert it to:\n\n```ts\nimport { registerEnumType } from '@nestjs/graphql'\n\nexport enum UserStatus {\n  ACTIVE = 'ACTIVE',\n  INACTIVE = 'INACTIVE',\n}\n\nregisterEnumType(UserStatus, { name: 'UserStatus' })\n```\n\n## Command: gql-assist\n\nGQL Assist is a powerful tool designed to streamline the development of GraphQL APIs in a NestJS\nenvironment. By automatically converting TypeScript classes, resolvers, and enums into their\ncorresponding GraphQL definitions, GQL Assist significantly reduces the amount of boilerplate code\nyou need to write.\n\n```sh\n\ngql-assist   \u003cgenerate|create\u003e [--help] [--doc] [--version]\n\nCOMMANDS\n\ngenerate    GraphQL Assist converts GraphQL queries, mutations or subscriptions\n\ncreate      Create a module\n\nCOMMON\n\n--help      Show help\n\n--doc       Generate documentation\n\n--version   Show version\n\n```\n\n## gql-assist generate\n\nGraphQL Assist converts GraphQL queries, mutations or subscriptions\n\n```sh\n\ngql-assist generate   \u003chook|decorator\u003e\n\nCOMMANDS\n\nhook        GraphQL Assist converts GraphQL queries into TypeScript code compatible\n            with @apollo/client or similar library, making query writing for\n            Apollo Client easier and less error-prone.\n\ndecorator   Automatically converts TypeScript classes, resolvers, methods,\n            and enums to their respective NestJS GraphQL or Type GraphQL counterparts\n            with appropriate decorators.\n\n```\n\n\u003e ### gql-assist generate hook\n\u003e\n\u003e GraphQL Assist converts GraphQL queries into TypeScript code compatible with @apollo/client or\n\u003e similar library, making query writing for Apollo Client easier and less error-prone.\n\u003e\n\u003e ```sh\n\u003e\n\u003e gql-assist generate hook   [--schema=\u003cstring\u003e] [--file=\u003cstring\u003e] [--pattern=\u003cstring\u003e]\n\u003e                            [--ignore=\u003cstring\u003e]\n\u003e\n\u003e OPTIONS\n\u003e\n\u003e --schema=\u003cstring\u003e    Schema file\n\u003e\n\u003e --file=\u003cstring\u003e      The source file to inspect and generate\n\u003e\n\u003e --pattern=\u003cstring\u003e   Pattern to identify the files to process\n\u003e\n\u003e --ignore=\u003cstring\u003e    Folders to ignore\n\u003e\n\u003e ```\n\u003e\n\u003e ### gql-assist generate decorator\n\u003e\n\u003e Automatically converts TypeScript classes, resolvers, methods, and enums to their respective\n\u003e NestJS GraphQL or Type GraphQL counterparts with appropriate decorators.\n\u003e\n\u003e ```sh\n\u003e\n\u003e gql-assist generate decorator   [--file=\u003cstring\u003e] [--pattern=\u003cstring\u003e] [--ignore=\u003cstring\u003e]\n\u003e\n\u003e OPTIONS\n\u003e\n\u003e --file=\u003cstring\u003e      The source file to inspect and generate\n\u003e\n\u003e --pattern=\u003cstring\u003e   Pattern to identify the files to process\n\u003e\n\u003e --ignore=\u003cstring\u003e    Folders to ignore\n\u003e\n\u003e ```\n\n## gql-assist create\n\nCreate a module\n\n```sh\n\ngql-assist create   \u003cname\u003e\n\nARGUMENTS\n\nname        Name of the module\n\n```\n\n## VSCode Extension\n\nFor an enhanced development experience, you can install the\n[GraphQL Assist](https://marketplace.visualstudio.com/items?itemName=rintoj.gql-assist) extension\nfrom the Visual Studio Code Marketplace. This extension provides in-editor completions and\nsuggestions, making it even easier to work with GraphQL and NestJS.\n\n1. Open Visual Studio Code.\n2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of\n   the window or by pressing `Ctrl+Shift+X`.\n3. Search for \"GraphQL Assist\".\n4. Click the Install button to install the extension.\n5. Once installed, the extension will provide code completions and suggestions directly within your\n   IDE.\n\n## Contributing\n\nWe welcome contributions to GQL Assist! If you have any ideas, suggestions, or bug reports, please\nopen an issue or submit a pull request on our GitHub repository.\n\n## License\n\nGQL Assist is licensed under the MIT License. See the LICENSE file for more information.\n\n---\n\nGQL Assist aims to make your development experience smoother and more efficient by automating the\nrepetitive tasks involved in setting up a GraphQL server with NestJS. Enjoy coding with less\nboilerplate and more focus on your application's core functionality!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Fgql-assist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frintoj%2Fgql-assist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Fgql-assist/lists"}