Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement mirageJS+graphql for a flutter project which is using graphql-flutter as graphql client #4

Open
Sanfrnds opened this issue Oct 3, 2020 · 0 comments

Comments

@Sanfrnds
Copy link

Sanfrnds commented Oct 3, 2020

Hi Sam,

Can we have a small example on implement mirageJS+graphql for a flutter project which is using graphql-flutter as graphql client.

i have tried your example but facing below issue:

server is running at "http:localhost:3000", i have used your below github example

now, i used the graphql_flutter library in my flutter project and send the request to server, but got below error:

I/flutter (20369):

I/flutter (20369):

I/flutter (20369):

I/flutter (20369):

I/flutter (20369): <title>Error</title>

I/flutter (20369):

I/flutter (20369):

I/flutter (20369):

Cannot POST /graphql

I/flutter (20369):

I/flutter (20369):

//Code i have used in flutter app

..... rest of the code.....

return GraphQLProvider(
client: Client.client,
child: Query(
options: QueryOptions(
documentNode: gql(Queries.placeholderQuery),// string containing query
),
builder: (QueryResult result,
{VoidCallback refetch, FetchMore fetchMore}) {
if (result.hasException) {
return Text(result.exception.toString());
}
if (result.loading) {
return Expanded(
child: Center(child: CircularProgressIndicator()),
);
}
if (result.data == null) {
return Text("No Data Found !");
}

//client url is
class Client {
static ValueNotifier client = ValueNotifier(GraphQLClient(
cache: OptimisticCache(
dataIdFromObject: typenameDataIdFromObject,
),
// used 10.0.2.2 because using android emulator, so 10.0.2.2 is alias for localhost
link: HttpLink(uri: "http://10.0.2.2:3000/graphql")));
}

//query is
static String placeholderQuery = """
query {
movies {
id
title
}
}""";
}

i know i'm doing something wrong, but not able to figure out.Please let me know if you need more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant