{"id":18930058,"url":"https://github.com/labd/storyblok-graphql-codegen-terraform","last_synced_at":"2026-04-07T19:01:09.443Z","repository":{"id":171980186,"uuid":"648679196","full_name":"labd/storyblok-graphql-codegen-terraform","owner":"labd","description":"A graphql codegen plugin that generates terraform code for Storyblok based on a GraphQL schema","archived":false,"fork":false,"pushed_at":"2026-04-07T14:28:09.000Z","size":703,"stargazers_count":0,"open_issues_count":9,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-07T15:27:08.006Z","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/labd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-06-02T14:34:20.000Z","updated_at":"2026-04-07T14:27:45.000Z","dependencies_parsed_at":"2024-04-09T10:31:10.089Z","dependency_job_id":"5f564246-a46f-4019-b65a-9401b569c7e9","html_url":"https://github.com/labd/storyblok-graphql-codegen-terraform","commit_stats":null,"previous_names":["labd/storyblok-graphql-codegen-terraform"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/labd/storyblok-graphql-codegen-terraform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fstoryblok-graphql-codegen-terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fstoryblok-graphql-codegen-terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fstoryblok-graphql-codegen-terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fstoryblok-graphql-codegen-terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labd","download_url":"https://codeload.github.com/labd/storyblok-graphql-codegen-terraform/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fstoryblok-graphql-codegen-terraform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31524531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":"2024-11-08T11:36:22.444Z","updated_at":"2026-04-07T19:01:09.335Z","avatar_url":"https://github.com/labd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# storyblok-graphql-codegen-terraform\n\nThis is a plugin for GraphQL Codegen that outputs your schema to Storyblok resources in Terraform.\n\nThis terraform code is dependent on the [Storyblok Terraform provider](https://registry.terraform.io/providers/labd/storyblok/latest).\n\nFor an example output see [the example output terraform file](examples/output/example.tf).\n\nFor more information on the Storyblok Terraform provider, see the documentation on the [terraform registry](https://registry.terraform.io/providers/labd/storyblok/latest/docs).\n\n# codegen.yml\n\nA basic example:\n\n```yml\noverwrite: true\nconfig:\n  sort: false\nschema:\n  - storyblok-graphql-codegen-terraform\n  - ./schemas/example.graphql\nhooks:\n  afterAllFileWrite:\n    - terraform fmt\ngenerates:\n  terraform/example.tf:\n    plugins:\n      - storyblok-graphql-codegen-terraform\n    config:\n      space_id: 123\n      sort_resources: true\n```\n\n## Configuration options\n- `sort_resources` can be used to sort the resources in the terraform output. This can be used to avoid random sorting which can cause differences in your git changes each time you run the codegenerator.\u003cbr\u003e\nIt is also adviced to set the global `sort` option to `false` since that will also sort the field definitions, which impacts the Storyblok UI itself.\n\n# Your Graphql file\n\nBasic example:\n\n```graphql\n# For root content types, add the `@storyblok(type: contentType)` directive\ntype Page @storyblok(type: contentType) {\n  # Add a `@storyblokField` directive to add extra configuration for a field such as translations\n  seoTitle: String @storyblokField(translatable: true, section: \"SEO\")\n  seoDescription: String @storyblokField(translatable: true, section: \"SEO\")\n\n  blocks: [Block] @storyblokField\n}\n\nunion Block = MarkdownBlock | BannerBlock\n\n# By default a type is a nested Storyblok component\ntype MarkdownBlock @storyblok {\n  content: String @storyblokField(format: markdown, translatable: true)\n}\n\ntype BannerBlock @storyblok(icon: block_image) {\n  title: String @storyblokField(translatable: true)\n  link: StoryblokLink @storyblokField\n  image: StoryblokAsset! @storyblokField(filetypes: [image])\n}\n\ntype ProductListBlock @storyblok {\n  title: String @storyblokField(translatable: true)\n}\n\ntype Article @storyblok {\n  # This field will be ignored\n  systemField: String\n  date: Date @storyblokField\n  author: String @storyblokField\n  content: String @storyblokField(format: markdown, translatable: true)\n}\n```\n\n## Advanced examples\n\n### Tabs and Sections\n\nFields can be grouped into tabs and/or sections with corresponding storyblokField arguments.\n\n```graphql\ntype A @storyblok {\n  a: String @storyblokField(tab: \"my-tab\")\n  b: String @storyblokField(tab: \"my-tab\")\n  c: String @storyblokField(section: \"my-section\")\n}\n```\n\n### Story Option Type\n\nA story option type renders a dropdown list with available stories.\n\nTo create an option field with a story reference, create a field that references to `contentType` or `universal`.\n\n```graphql\ntype A @storyblok {\n  story: Story @storyblokField(folder: \"{0}/some-folder\")\n}\n\ntype Story @storyblok(type: contentType) {\n  name: String @storyblokField\n}\n```\n\nSimilarly, you'll get an options field if you provide an array.\nFurthermore, the reference may also be a union type.\nBut if so, all types of the union type must either be a `contentType` or a `universal` type.\n\n# Your resolvers file\n\nThis repository also contains a set of resolvers that can be used to do a couple of things:\n\n- resolve internal and external links\n- resolve an `id` field (based on the `_uid` field)\n- resolve single blok fields\n- resolve rich text as a serialized JSON string\n- resolve union types\n- resolve stories for single and multiple option fields\n\n## Usage\n\n```ts\nimport { logger } from '@commerce-backend/observability'\nimport { mergeResolvers } from '@graphql-tools/merge'\nimport {\n  storyblokResolvers,\n  updateContext,\n} from 'storyblok-graphql-codegen-terraform/resolvers'\nimport StoryblokClient from 'storyblok-js-client'\nimport { typeDefs } from './typedefs.js'\n\nconst client = new StoryblokClient({\n  accessToken: process.env.STORYBLOK_ACCESS_TOKEN,\n})\n\nexport const customResolvers = {\n  Query: {\n    contentPage: (_parent, args, context, _info) =\u003e\n      client\n        .get(`cdn/stories/pages/${args.path}`, {\n          resolve_links: 'url', // this is required for the link resolver to work\n          resolve_relations: ['content_page.usps'], // TODO: make this dynamic\n        })\n        // Use the update context so the resolvers can resolve links and story options\n        .then(updateContext(context))\n        .then((response) =\u003e ({\n          ...response.data?.story.content,\n          pageId: response.data?.story.id,\n        })),\n  },\n}\n\nconst resolvers = mergeResolvers([\n  // include all storyblok resolvers\n  storyblokResolvers(typeDefs, {\n    // optionally modify the relative story paths for the link resolver\n    slugResolver: (fullPath) =\u003e fullPath.split('/pages/')?.[1] ?? fullPath,\n  }),\n  // add your own resolvers\n  customResolvers,\n])\n\nexport default resolvers\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fstoryblok-graphql-codegen-terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabd%2Fstoryblok-graphql-codegen-terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fstoryblok-graphql-codegen-terraform/lists"}