0 purchases
simple graphql query builder gen
A helper package to support file generation for simple_graphql_query_builder
Usage #
Add dependency to your dev_dependencies:
dev_dependencies:
simple_graphql_query_builder_gen: ^0.1.0
copied to clipboard
Annotate class with @QueryResult
@QueryResult
class User {
@QueryResultField({name: 'username'})
final String name;
@QueryResultField({ignore: true})
final int age;
const User({required this.name, required this.age,});
}
copied to clipboard
Add part file_name.g.dart to corresponding class.
Generate class using the following command:
flutter pub run build_runner build --delete-conflicting-outputs
copied to clipboard
or
dart pub run build_runner build --delete-conflicting-outputs
copied to clipboard
Annotation #
QueryResult #
To annotate the object whose fields who what to be used for QueryBuilder.fields
Example usage, the 2 below generates the same result
@QueryResult
class MyClass {
final String? name;
const MyClass({required this.name});
}
copied to clipboard
@queryResult
class MyClass {
final String? name;
const MyClass({required this.name});
}
copied to clipboard
QueryResultField #
To annotate the object's individual field whose fields who what to be used for QueryBuilder.fields
Example usage, the 2 below generates the same result
@queryResult
class Example {
final String? name;
@QueryResultField(ignore: false, name: 'Test', isCustomType: true)
final InnerExample? innerExample;
@QueryResultField(isCustomType: true)
final InnerExample innerExample2;
const Example({
this.name,
this.innerExample,
required this.innerExample2,
});
}
copied to clipboard
Will have the folowwing result, you can use the functions to provide to QueryBuilder parameter fields
final Map<String, dynamic> exampletoQueryResult = {
'name': null,
'Test2': innerExampletoQueryResult,
'innerExample2': innerExampletoQueryResult,
};
final Map<String, dynamic> innerExampletoQueryResult = {
'innerField1': null,
};
copied to clipboard
Arguments
Name
Default Value
Is required
Description
name
name of field
false
To change the name of the field in the genrated method
isCustomType
false
if type is user created
If type is user created type, MUST mark as true
ignore
false
false
Set to true to remove the field from the generated method
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.