masamune_model_firebase_data_connect_annotation 3.1.1 copy "masamune_model_firebase_data_connect_annotation: ^3.1.1" to clipboard
masamune_model_firebase_data_connect_annotation: ^3.1.1 copied to clipboard

Define annotations to use the masamune firebase data connect builder. Build with masamune_model_firebase_data_connect_builder using this annotation.

Masamune logo

Masamune Model FirebaseDataConnect

Follow on GitHub Follow on X Follow on YouTube Maintained with Melos

GitHub Sponsor


[GitHub] | [YouTube] | [Packages] | [X] | [LinkedIn] | [mathru.net]


Masamune Model Firebase Data Connect Annotation #

Overview #

masamune_model_firebase_data_connect_annotation provides annotations for code generation with Firebase Data Connect. This is a companion package that works with the builder and runtime packages.

Package Roles:

  • masamune_model_firebase_data_connect_annotation (this package) - Provides annotations
  • masamune_model_firebase_data_connect_builder - Generates GraphQL schemas and adapters
  • masamune_model_firebase_data_connect - Runtime adapter implementation

Usage #

This package is automatically included when you use the full Firebase Data Connect stack. Install all three packages:

flutter pub add masamune_model_firebase_data_connect
flutter pub add masamune_model_firebase_data_connect_annotation
flutter pub add --dev masamune_model_firebase_data_connect_builder

Annotations #

@firebaseDataConnect #

Mark models that should generate Firebase Data Connect schemas with permission settings:

import 'package:masamune_model_firebase_data_connect_annotation/masamune_model_firebase_data_connect_annotation.dart';

@freezed
@formValue
@immutable
@firebaseDataConnect  // Enables Data Connect generation
@CollectionModelPath(
  'user',
  permission: [
    AllowReadModelPermissionQuery.allUsers(),   // All users can read
    AllowWriteModelPermissionQuery.allUsers(),  // All users can write
  ],
)
class UserModel with _$UserModel {
  const factory UserModel({
    required String name,
    @Default('') String email,
  }) = _UserModel;
  // ... rest of model
}

@FirebaseDataConnectAdapter #

Configure custom adapter settings:

@FirebaseDataConnectAdapter(
  connector: "my-connector",     // Connector name
  service: "my-service",         // Service name
  location: "us-central1",       // Cloud location
  outputDirectory: "firebase/dataconnect",  // Output path
)
@firebaseDataConnect
@CollectionModelPath('post')
class PostModel with _$PostModel {
  // ... model definition
}

Code Generation #

After annotating your models, run:

katana code generate

This generates:

  • GraphQL schema files (.gql)
  • Query and mutation definitions
  • connector.yaml configuration
  • *.dataconnect.dart adapter implementations

For Full Documentation #

See the complete Firebase Data Connect integration guide in the masamune_model_firebase_data_connect package.

GitHub Sponsors #

Sponsors are always welcome. Thank you for your support!

https://github.com/sponsors/mathrunet

1
likes
150
points
587
downloads

Publisher

verified publishermathru.net

Weekly Downloads

Define annotations to use the masamune firebase data connect builder. Build with masamune_model_firebase_data_connect_builder using this annotation.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

katana, masamune_annotation, meta

More

Packages that depend on masamune_model_firebase_data_connect_annotation