Skip to content

Commit

Permalink
fix flutter storage issue
Browse files Browse the repository at this point in the history
  • Loading branch information
micimize committed Apr 27, 2019
1 parent b33da41 commit 37f1869
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ example/lib/local.dart
# Coverage
coverage.json
coverage/*

# example build files
packages/graphql_flutter/example/android/.project
packages/graphql_flutter/example/android/.settings/
packages/graphql_flutter/example/android/app/.classpath
packages/graphql_flutter/example/android/app/.project
packages/graphql_flutter/example/android/app/.settings/
13 changes: 8 additions & 5 deletions packages/graphql_flutter/lib/src/caches.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import 'package:meta/meta.dart';
import 'dart:async' show FutureOr;
import 'dart:io' show Directory;

import 'package:meta/meta.dart';
import 'package:path_provider/path_provider.dart'
show getApplicationDocumentsDirectory;

import 'package:graphql/client.dart' as client;

const client.StorageProvider storageProvider = getApplicationDocumentsDirectory;
FutureOr<Directory> flutterStorageProvider() =>
getApplicationDocumentsDirectory();

class InMemoryCache extends client.InMemoryCache {
InMemoryCache() : super(storageProvider: storageProvider);
InMemoryCache() : super(storageProvider: flutterStorageProvider);
}

class NormalizedInMemoryCache extends client.NormalizedInMemoryCache {
Expand All @@ -18,7 +21,7 @@ class NormalizedInMemoryCache extends client.NormalizedInMemoryCache {
}) : super(
dataIdFromObject: dataIdFromObject,
prefix: prefix,
storageProvider: storageProvider,
storageProvider: flutterStorageProvider,
);
}

Expand All @@ -29,6 +32,6 @@ class OptimisticCache extends client.OptimisticCache {
}) : super(
dataIdFromObject: dataIdFromObject,
prefix: prefix,
storageProvider: storageProvider,
storageProvider: flutterStorageProvider,
);
}

0 comments on commit 37f1869

Please sign in to comment.