zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.23k stars 613 forks source link

Operation not permitted when init by initHiveForFlutter #1380

Closed kurt-liao closed 10 months ago

kurt-liao commented 10 months ago

I got an error when I init the app by function initHiveForFlutter with debug mode in the VSCode.

Here is the error message:

PathAccessException (PathAccessException: Cannot open file, path = '/Users/august/Documents/graphqlclientstore.hive' (OS Error: Operation not permitted, errno = 1))

I know the function initHiveForFlutter is to init Hive with the document folder, but why it requires the permission? I search a while and think it doesn't need that permission.

My code get stuck at the first line in main

Future<void> main(List<String> args) async {
  await initHiveForFlutter(); // Exception occurred
  ...
}

Environment macOS flutter: 3.10.6 graphql_flutter: 5.1.2

Expected behavior

Init Hive without exception and should not ask for permission.

screenshots

Screen Shot 2023-09-18 at 10 44 39 PM

vincenzopalazzo commented 10 months ago

OS Error: Operation not permitted, errno = 1))

This is a an OS error, we can not do nothing (maybe)/ Have you try to see if you have enough permission?

kurt-liao commented 10 months ago

Have you try to see if you have enough permission?

Thanks for the quick reply. Yes, I have tried to give the Document folder permission, and it will work. However, I don't want to ask permission from the user on my app if possible.

Or is it possible to change the init folder that I specify?

vincenzopalazzo commented 10 months ago

I guess this is related to the app, we can not do nothing from the graphql package I think

kurt-liao commented 10 months ago

I guess this is related to the app, we can not do nothing from the graphql package I think

@vincenzopalazzo I see, thanks. As I know Hive is used for caching in graphql_flutter, can I skip the initHiveForFlutter method if I don't need a cache in my app?

vincenzopalazzo commented 10 months ago

Yeah you can disable the cache and use the in-memory one or just nothing, you can take a look at the readme inside the package that you are using.

I am closing this due that it is an problem that we can not solve from the library point of view