{"id":28520001,"url":"https://github.com/source-c/go-gql2j","last_synced_at":"2026-02-03T14:08:33.675Z","repository":{"id":291479936,"uuid":"975145843","full_name":"source-c/go-gql2j","owner":"source-c","description":"Basic GraphQL schema to Java classes generator written in Golang.","archived":false,"fork":false,"pushed_at":"2025-04-29T21:30:16.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T07:36:45.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/source-c.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-29T21:23:21.000Z","updated_at":"2025-04-29T21:30:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1389f42-720a-4f2e-b1ca-b8572a76be8c","html_url":"https://github.com/source-c/go-gql2j","commit_stats":null,"previous_names":["source-c/go-gql2j"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/source-c/go-gql2j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-c%2Fgo-gql2j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-c%2Fgo-gql2j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-c%2Fgo-gql2j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-c%2Fgo-gql2j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/source-c","download_url":"https://codeload.github.com/source-c/go-gql2j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/source-c%2Fgo-gql2j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29047301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-06-09T06:38:01.272Z","updated_at":"2026-02-03T14:08:33.666Z","avatar_url":"https://github.com/source-c.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL to Java (gql2j)\n\nA Go tool that generates Java classes from GraphQL schemas with support for Lombok, JSR-303 validation, custom type mappings, and directives.\n\n## Installation\n\n```bash\ngo install github.com/source-c/go-gql2j/cmd/gql2j@latest\n```\n\nOr build from source:\n\n```bash\ngit clone https://github.com/source-c/go-gql2j.git\ncd go-gql2j\ngo build -o gql2j ./cmd/gql2j\n```\n\n## Quick Start\n\n```bash\n# Basic usage\ngql2j -schema schema.graphql -output ./generated -package com.example.model\n\n# With config file\ngql2j -config gql2j.yaml\n\n# With Lombok and validation\ngql2j -schema schema.graphql -output ./generated -package com.example.model -lombok -validation\n```\n\n## CLI Flags\n\n| Flag | Description |\n|------|-------------|\n| `-config` | Path to YAML config file |\n| `-schema` | GraphQL schema path (overrides config) |\n| `-output` | Output directory (overrides config) |\n| `-package` | Java package name (overrides config) |\n| `-java-version` | Target Java version: 8, 11, 17, 21 |\n| `-lombok` | Enable Lombok annotations |\n| `-lombok-disable` | Disable Lombok annotations |\n| `-validation` | Enable JSR-303 validation |\n| `-validation-disable` | Disable JSR-303 validation |\n| `-validation-package` | Validation package: `jakarta` or `javax` |\n| `-clean` | Clean output directory before generating |\n| `-verbose` | Enable verbose output |\n| `-version` | Print version information |\n\n## Configuration File\n\nCreate a `gql2j.yaml` file (see `gql2j.yaml.example` for full options):\n\n```yaml\nschema:\n  path: \"./schema.graphql\"\n  includes:\n    - \"./types/*.graphql\"\n\noutput:\n  directory: \"./generated\"\n  package: \"com.example.model\"\n\njava:\n  version: 17\n  fieldVisibility: \"private\"\n  collectionType: \"List\"\n  nullableHandling: \"wrapper\"\n  naming:\n    fieldCase: \"camelCase\"\n    classSuffix: \"\"\n    interfacePrefix: \"\"\n\ntypeMappings:\n  scalars:\n    DateTime:\n      javaType: \"java.time.LocalDateTime\"\n      imports: [\"java.time.LocalDateTime\"]\n    UUID:\n      javaType: \"java.util.UUID\"\n      imports: [\"java.util.UUID\"]\n\nfeatures:\n  lombok:\n    enabled: true\n    data: true\n    builder: true\n    noArgsConstructor: true\n  validation:\n    enabled: true\n    package: \"jakarta\"\n    notNullOnNonNull: true\n```\n\n## Supported Directives\n\n| Directive | Target | Effect |\n|-----------|--------|--------|\n| `@skip` | Type, Field | Exclude from generation |\n| `@javaName(name: \"...\")` | Type, Field, Enum Value | Override Java name |\n| `@javaType(type: \"...\", imports: [...])` | Field | Custom Java type |\n| `@deprecated(reason: \"...\")` | Field, Enum Value | Add `@Deprecated` |\n| `@annotation(value: \"...\", imports: [...])` | Type, Field | Add custom annotation |\n| `@constraint(...)` | Field | JSR-303 validation |\n| `@lombok(exclude: [...], include: [...])` | Type | Per-type Lombok config |\n| `@collection(type: \"Set\")` | Field | Override collection type |\n\n### Directive Examples\n\n```graphql\ntype User @lombok(exclude: [\"builder\"]) {\n  id: ID! @javaType(type: \"java.util.UUID\", imports: [\"java.util.UUID\"])\n  email: String! @constraint(pattern: \"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$\")\n  tags: [String] @collection(type: \"Set\")\n  legacyField: String @deprecated(reason: \"Use newField instead\")\n}\n\ntype Entity @annotation(value: \"@Entity\", imports: [\"jakarta.persistence.Entity\"]) {\n  id: ID!\n}\n\ntype Internal @skip {\n  secret: String\n}\n```\n\n### Constraint Directive Options\n\n```graphql\nfield: String @constraint(\n  minLength: 1,\n  maxLength: 100,\n  min: 0,\n  max: 150,\n  pattern: \"^[a-z]+$\",\n  notNull: true,\n  notBlank: true,\n  email: true\n)\n```\n\n## Example\n\nFor a GraphQL schema:\n\n```graphql\ntype User {\n  id: ID!\n  name: String\n  email: String!\n  posts: [Post]\n  role: UserRole\n}\n\ntype Post {\n  id: ID!\n  title: String!\n  content: String\n  author: User!\n}\n\nenum UserRole {\n  ADMIN\n  USER\n  GUEST\n}\n\ninterface Node {\n  id: ID!\n}\n\ninput CreatePostInput {\n  title: String!\n  content: String!\n}\n```\n\nGenerated `User.java` (with Lombok and validation enabled):\n\n```java\npackage com.example.model;\n\nimport jakarta.validation.constraints.NotNull;\nimport java.util.List;\nimport lombok.Data;\nimport lombok.NoArgsConstructor;\n\n@Data\n@NoArgsConstructor\npublic class User {\n\n    @NotNull\n    private String id;\n\n    private String name;\n\n    @NotNull\n    private String email;\n\n    private List\u003cPost\u003e posts;\n\n    private UserRole role;\n}\n```\n\n## Library Usage\n\nUse gql2j as a library in your Go code:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/source-c/go-gql2j/pkg/api\"\n)\n\nfunc main() {\n    result, err := api.GenerateToDir(api.Options{\n        SchemaPath:       \"schema.graphql\",\n        OutputDir:        \"./generated\",\n        Package:          \"com.example.model\",\n        JavaVersion:      17,\n        EnableLombok:     true,\n        EnableValidation: true,\n    })\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Printf(\"Generated %d files\\n\", len(result.Files))\n}\n```\n\n## Nullable Handling\n\nConfigure how nullable GraphQL fields are represented in Java:\n\n| Mode | Description | Example |\n|------|-------------|---------|\n| `wrapper` | Use wrapper types (default) | `Integer`, `Boolean` |\n| `optional` | Use `Optional\u003cT\u003e` | `Optional\u003cInteger\u003e` |\n| `annotation` | Use `@Nullable` annotation | `@Nullable Integer` |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-c%2Fgo-gql2j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsource-c%2Fgo-gql2j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsource-c%2Fgo-gql2j/lists"}