Plugins
Dart
Flutter-Freezed

Plugin Details

Package name@graphql-codegen/flutter-freezed
Weekly Downloadsdownloads
Versionlicense
Licenselicense
UpdatedAug 11th, 2022

Installation

yarn add -D @graphql-codegen/flutter-freezed

The flutter-freezed plugin generates [Freezed] models using a GraphQL Schema.

Please refer the the Flutter Freezed Guide for how to get started with this plugin.

configure the flutter-freezed plugin

Config API Reference

camelCasedEnums

type: boolean default: true

Dart's recommended lint uses camelCase for enum fields. Set this option to false to use the same case as used in the GraphQL Schema but note this can cause lint issues.

Usage Examples

generates:
  flutter_app/lib/data/models/app_models.dart
    plugins:
      - flutter-freezed
    config:
      camelCasedEnums: true

customScalars

type: object default: [object Object]

map custom Scalars to Dart built-in types

Usage Examples

generates:
  flutter_app/lib/data/models/app_models.dart
    plugins:
      - flutter-freezed
    config:
      customScalars:
        {
          "jsonb": "Map<String, dynamic>",
          "timestamptz": "DateTime",
          "UUID": "String",
        }

fileName

type: string default: app_models

this fileName will be used for the generated output file

Usage Examples

generates:
  flutter_app/lib/data/models/app_models.dart
    plugins:
      - flutter-freezed
    config:
      fileName: app_models
 

globalFreezedConfig

type: FreezedConfig default: DefaultFreezedConfig

use the same Freezed configuration for every generated output

typeSpecificFreezedConfig

type: Record_1 default: undefined

override the globalFreezedConfig for specific types. The GraphQL Type name is the key

ignoreTypes

type: string[] default: ``

names of GraphQL types to ignore when generating Freezed classes

Usage Examples

generates:
  flutter_app/lib/data/models/app_models.dart
    plugins:
      - flutter-freezed
    config:
      ignoreTypes: ["PaginatorInfo"]
 
Last updated on August 18, 2022