Frequently Asked Questions

Product Overview & Use Cases

What is Hygraph and how can it be used with Flutter?

Hygraph is a GraphQL-native headless CMS that enables developers to manage and deliver content efficiently to web and mobile applications. In the context of Flutter, Hygraph can power dynamic apps by providing a flexible API for content delivery, enabling real-time updates, and streamlining content management for developers. For example, you can architect a fan club app in Flutter that fetches show data from Hygraph using GraphQL queries. (Source)

What are some typical use cases for Hygraph?

Hygraph is used across industries for powering websites, mobile apps, eCommerce platforms, media and publishing, education technology, and more. Case studies include companies like Samsung (consumer electronics), Dr. Oetker (food and beverage), HolidayCheck (travel and hospitality), and Komax (industrial automation), each leveraging Hygraph for scalable, modern digital experiences. (Case Studies)

Features & Capabilities

What are the key features of Hygraph?

Hygraph offers a GraphQL-native architecture, content federation, scalability, and a flexible schema definition tool. It supports integrations with popular platforms (Netlify, Vercel, Shopify, AWS S3, Cloudinary, etc.), provides enterprise-grade security, and enables rapid content delivery for improved user experience and SEO. (Features)

Does Hygraph provide an API for content management?

Yes, Hygraph provides a powerful GraphQL API that allows you to fetch and manage content efficiently. This API is ideal for integrating with frameworks like Flutter, enabling dynamic content delivery and real-time updates. (API Reference)

What integrations are available with Hygraph?

Hygraph supports a wide range of integrations, including hosting and deployment (Netlify, Vercel), eCommerce (Shopify, BigCommerce, commercetools), localization (Lokalise, Crowdin, Smartling), digital asset management (AWS S3, Cloudinary, Bynder, Aprimo), personalization (Ninetailed), and AI (AltText.ai). (Integrations)

Technical Requirements & Implementation

How do I fetch and render content from Hygraph in a Flutter app?

You can fetch and render content from Hygraph in Flutter by using the graphql_flutter package to send GraphQL queries to the Hygraph API. Start by cloning a sample Hygraph blog app project, which includes basic content models. The process involves defining your schema in Hygraph, setting up a GraphQL client in Flutter, and using providers (e.g., Riverpod) to manage state and data fetching. (Flutter Implementation Guide)

What are the prerequisites for using Flutter with Hygraph?

To use Flutter with Hygraph, you need the Flutter SDK and its dependencies installed, basic knowledge of Dart, and an iOS simulator and/or Android Studio on your machine. These prerequisites ensure you can build, test, and deploy your Flutter app integrated with Hygraph. (Flutter Implementation Guide)

What resources are available for implementing Hygraph with Flutter?

Hygraph provides a Flutter connection guide, a basic blog app example, starter templates, and documentation to help you integrate Hygraph with Flutter. These resources cover everything from initial setup to advanced content modeling and API usage.

Pricing & Plans

What is Hygraph's pricing model?

Hygraph offers a free forever Hobby plan, a Growth plan starting at $199/month, and custom Enterprise plans. For the most up-to-date details, visit the Hygraph Pricing Page.

Security & Compliance

What security and compliance certifications does Hygraph have?

Hygraph is SOC 2 Type 2 compliant, ISO 27001 certified, and GDPR compliant. It offers features like SSO integrations, audit logs, encryption at rest and in transit, and sandbox environments to protect sensitive data and meet regulatory standards. (Security Features)

Customer Success & Case Studies

Can you share specific customer success stories using Hygraph?

Yes. For example, Komax achieved a 3X faster time to market, Autoweb saw a 20% increase in website monetization, and Samsung improved customer engagement with a scalable platform. Dr. Oetker enhanced their digital experience using MACH architecture. More stories are available on the Hygraph product page.

Support & Training

What support and training does Hygraph offer?

Hygraph provides 24/7 support via chat, email, and phone. Enterprise customers receive dedicated onboarding and expert guidance. All users have access to documentation, video tutorials, webinars, and a community Slack channel. (Contact Page)

Performance & Metrics

How does Hygraph optimize content delivery performance?

Hygraph emphasizes rapid content distribution and responsiveness, which improves user experience, engagement, and search engine rankings. Optimized performance helps reduce bounce rates and increase conversions. (Performance Details)

Getting Started

How easy is it to get started with Hygraph?

Hygraph is designed for ease of use, with an intuitive interface praised by customers. Even non-technical users can start quickly by signing up for a free account and using onboarding guides and documentation. For example, Top Villas launched a new project in just 2 months. (Documentation, Top Villas Case Study)

Customer Proof

Who are some of Hygraph's customers?

Hygraph is trusted by companies such as Sennheiser, HolidayCheck, Ancestry, Samsung, Dr. Oetker, Epic Games, Bandai Namco, Gamescom, Leo Vegas, and Clayton Homes. (Case Studies)

Velocity at Scale: Join the Launch of Hygraph’s Latest AI Innovations

Hygraph for Fluttering Parrotheads

Let's architect a simple Jimmy Buffett Fan Club app in Flutter, powered by Hygraph.
Adam Smith

Written by Adam 

Jun 12, 2024
Hygraph for Fluttering Parrotheads

There’s not a lot of articles online about Jimmy Buffett and production-ready Flutter architecture. Excuse me. Jimmy Buffett GraphQL and production-ready Flutter architecture – common mistake.

We’re here to remedy all that, so buckle up Parrot Heads, let's architect a simple Jimmy Buffett Fan Club app in Flutter, powered by Hygraph, our favorite GraphQL CMS.

The Github repo for this tutorial can be found here.

#Architecture

There is no consensus on the best architecture for Flutter, but we’re going to go with Riverpod architecture today for a few reasons.

1. Scalability and flexibility: Riverpod offers a highly scalable architecture that is well-suited for large and complex applications. It provides a clear separation of concerns, making it easy to manage state across different parts of the app.

2. Performance and testing: Riverpod is designed with performance in mind, reducing unnecessary rebuilds and optimizing resource usage. Additionally, it simplifies the testing process by providing a more predictable and maintainable state management solution. With Riverpod, you can write unit tests for your state logic without relying on Flutter-specific code.

3. 🤌 Developer experience: Riverpod's robust tooling and integration with the Dart ecosystem improve the overall developer experience. It supports features like hot reload, state persistence, and dependency injection out of the box.

Riverpod has proven to be a solid choice in our Flutter apps and has held up well.

#Parrot Head fan club

The app we’re building today is very simple. It will display a list of the best Jimmy Buffett shows for our Parrot Head fan club. You can then click through to get details about the set list and how many fans have voted for this show.

We’ll be building this using Flutter Web but the same codebase is used to create iOS, Android, and desktop apps.

Parrot Head Fan Club

Parrot Head Fan Club preview

#CMS data model

To power this, we need to define the Show model in our Hygraph CMS, which will need things like a City, a Date, a Playlist, etc.

Our Hygraph schema for a Show is seen here.

Parrot Head Fan Club data model in CMS

#Building our app

In our Flutter app, we’re going to model this GraphQL schema using the Freezed package. To get started just add Freezed to your pubspec.yaml. Freezed is typically used with REST APIs, but there’s no reason you can’t use it with GraphQL. It provides all the same great time-saving benefits.

With this simple model file and the Freezed codegen tool:

import 'package:freezed_annotation/freezed_annotation.dart';
part 'show.freezed.dart';
part 'show.g.dart';
@freezed
class Show with _$Show {
const factory Show({
required String id,
required String city,
required String playlist,
required int vote_count,
required String date,
required String image_url,
}) = _Show;
factory Show.fromJson(Map<String, dynamic> json) => _$ShowFromJson(json);
}

We get the following out of the box (AKA we save a lot of typing):

  • a constructor + the properties
  • override toString, operator ==, hashCode
  • a copyWith method to clone the object
  • handling de/serialization

Now, in order to set up Riverpod and the Riverpod generator add the latest versions to your pubspec.yaml and simply wrap your entire app in a ProviderScope

import 'package:flutter/material.dart';
import 'package:graphqlparrot_head_flutter_tutorialtut/my_app.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
void main() {
runApp(ProviderScope(
child: MyApp(),
));
}

On now to setting up our Riverpod Provider.

import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:parrot_head_flutter_tutorial/models/show/show.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'shows_list_provider.g.dart';
@riverpod
class ShowsList extends _$ShowsList {
static const String query = """
query FetchShows {
shows() {
playlist
vote_count
date
city
stage
id
image_url
}
}
""";
final HttpLink httpLink = HttpLink(
"https://api-us-west-2.hygraph.com/v2/clwrd5jw5012l07w3ba2yuj4s/master");
@override
Future<List<Show>> build() async {
final client = GraphQLClient(
link: httpLink,
cache: GraphQLCache(),
);
final result = await client.query(QueryOptions(document: gql(query)));
final showsJSON = result.data!['shows'] as List<dynamic>;
return showsJSON.map((showJSON) => Show.fromJson(showJSON)).toList();
}
}

Here we’re setting up the Provider where we define how to fetch and manage the list of Shows using GraphQL. Let's break down the key parts of this setup:

We start by defining the GraphQL query that will fetch the list of shows from our Hygraph server. This query retrieves various details about each show, such as the playlist, vote count, date, city, ID, and image URL.

static const String query = """
query FetchShows {
shows() {
playlist
vote_count
date
city
id
image_url
}
}
""";

Next, we create an HttpLink to specify the endpoint of our Hygraph API. This will be used by the GraphQLClient to send requests to Hygraph. We can then instantiate a GraphQLClient which will be responsible for making the actual network requests.

final HttpLink httpLink = HttpLink(
"https://api-us-west-2.hygraph.com/v2/clwrd5jw5012l07w3ba2yuj4s/master");
final client = GraphQLClient(
link: httpLink,
cache: GraphQLCache(),
);

In the build method, we use the client to perform the query. The result is parsed from JSON into a list of Show objects.

Here are some key benefits of using Riverpod in this context:

  • Caching: Reduces network requests by storing fetched data in memory, allowing for reuse across different parts of the app.

  • Scalability: Manages complex state efficiently, making it easy to scale your app and maintain a clean architecture.

  • Consistency: Ensures uniform state management across the app, making the codebase more predictable and maintainable.

  • Performance: Minimizes unnecessary rebuilds, leading to a smoother user experience.

@override
Future<List<Show>> build() async {
final result = await client.query(QueryOptions(document: gql(query)));
final showsJSON = result.data!['shows'] as List<dynamic>;
return showsJSON.map((showJSON) => Show.fromJson(showJSON)).toList();
}

Now in the UI, the ShowsScreen widget listens to the showsListProvider using ref.watch. This provider returns an AsyncValue<List>, which represents the state of the asynchronous operation.

The when method is used to handle the different states of the AsyncValue:

data: Displays a list of shows using a ListView.builder. loading: Shows a CircularProgressIndicator while the data is being fetched. error: Displays an error message if there was an issue fetching the data.

import 'package:flutter/material.dart';
import 'package:parrot_head_flutter_tutorial/features/shows/providers/shows_list_provider.dart';
import 'package:parrot_head_flutter_tutorial/features/show/ui/show_screen.dart';
import 'package:parrot_head_flutter_tutorial/models/show/show.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class ShowsScreen extends ConsumerWidget {
ShowsScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final AsyncValue<List<Show>> showsRepo = ref.watch(showsListProvider);
return showsRepo.when(
data: (List<Show> shows) {
return Scaffold(
appBar: AppBar(
title: const Text("Best of Jimmy"),
),
body: ListView.builder(
itemCount: shows.length,
itemBuilder: (BuildContext context, int index) {
final Show show = shows[index];
return ListTile(
title: Text(show.city),
subtitle: Text(show.date),
leading: Image.network(show.image_url),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => ShowScreen(show: show),
),
);
},
);
},
),
);
},
loading: () => const CircularProgressIndicator(),
error: (Object error, StackTrace? stackTrace) {
return Scaffold(
appBar: AppBar(),
body: Center(child: Text("Error")),
);
},
);
}
}

Each show is displayed in a ListTile with the city name, date, and an image. When a show is tapped, it navigates to a ShowScreen with the details of the selected show. In a production app, we’d use the go_router package, but that’s outside the scope of this article.

#Summary

This guide delved into creating a production-ready Flutter app using Riverpod and Hygraph, focusing on state management and GraphQL integration. Riverpod is highlighted for its scalability, performance optimization, and enhanced developer experience. It ensures a clear separation of concerns, minimizes unnecessary rebuilds, and simplifies testing.

Hygraph is a great fit for easily serving up GraphQL for a Flutter mobile or web application. The powerful schema definition tools, the flexibility in managing content, and the efficient query performance make it an ideal choice for developers.

🎸🍹

Become a Hygraph partner

Discover the benefits of partnering with us and unlock new growth opportunities

Blog Author

Adam Smith

Adam Smith

Head of Engineering

Adam is the Head of Engineering at Beta Acid and is an MIT-trained technologist with a 20 year track record of successfully delivering digital products. His career has taken him around the world from Paris to Hawaii as a startup founder, product manager, engineering lead and Chief Operating Officer.

Share with others

Sign up for our newsletter!

Be the first to know about releases and industry news and insights.