getGalleryById method
- String id
override
Implementation
@override
Future<Gallery> getGalleryById(String id) async {
const query = r'''
query FindGallery($id: ID!) {
findGallery(id: $id) {
id
title
date
rating
image_count
details
}
}
''';
final result = await client.query(
QueryOptions(
document: gql(query),
variables: {'id': id},
),
);
if (result.hasException) throw result.exception!;
final data = result.data?['findGallery'];
if (data == null) throw Exception('Gallery not found');
return Gallery.fromJson(data as Map<String, dynamic>);
}