I want to get raw json data from GraphQL flutter.
here is part of the data I want to get:
{
"data": {
"countries": [
{
"name": "Andorra",
"code": "AD",
"native": "Andorra",
"phone": "376"
},
{
"name": "United Arab Emirates",
"code": "AE",
"native": "دولة الإمارات العربية المتحدة",
"phone": "971"
},
but this is the result that GraphQL returns to me:
{__typename: Query,
countries: [{__typename: Country, name: Andorra, code: AD, native: Andorra, phone: 376},
{__typename: Country, name: United Arab Emirates,
code: AE, native: دولة الإمارات العربية المتحدة, phone: 971},
the format is all wrong...
and this is my code:
void getCountryName() async {
pageState(AppState.loading);
String q = """
{
countries {
name
code
native
phone
}
}
""";
QueryResult res = await countriesClient.query(
QueryOptions(
document: gql(q),
optimisticResult: Country,
fetchPolicy: FetchPolicy.networkOnly,
),
);
}
print(res.data);