title: How to parse a graphql response in flutter
body: <p>I am trying to parse my graphql response from my neo4j-graphql backend in my flutter app. I am using the flutter_graphql plugin to make queries to the back end. However, when I try to parse the response(JSON) I am getting 'LinkHashMap is not a subtype of Users Map.'</p>
  
  <p>I tried modifying my serializing classes that will parse the response but to no available .below is the JSON response from neo4j graphql</p>
  
  <pre><code>
   /*I HAVE EDITED THE JSON RESPONSE. THE FULL JSON RESPONSE FROM THE SERVER IS AS BELOW*/
  {
    "data": {
      "User": [
        {
          "userId": 1,
          "city": "NewYork",
          "country": "User",
          "captionType": "User",
          "state": "New York",
          "firstName": "example2",
          "lastname": "example",
          "email": "example2@gmail.com"
        }
      ]
    },
    "extensions": {
      "type": "READ_ONLY"
    }
  }
  </code></pre>
  
  <p>below are the classes that represent the above response</p>
  
  <pre class="lang-dart prettyprint-override"><code>    @JsonSerializable()
      class User {
        final int userId;
        final String email ;
        final String country ;
        final String firstName;
        final String gender ;
        final String city ;
        final String dateOfBirth ;
        final String state;
        final String captionType;
        final String lastname;
       User({this.userId,this.email,this.country,this.firstName,this.gender,this.dateOfBirth,this.state,this.captionType,this.city,this.lastname});
  
       factory User.fromJson(Map&lt;String,dynamic&gt; json)=&gt; _$UserFromJson(json);
        Map&lt;String, dynamic&gt; toJson() =&gt; _$UserToJson(this);
  
      }
  
      class Users{
        final List&lt;User&gt;users;
        Users({this.users});
  
        factory Users.fromJson(Map&lt;String, dynamic&gt; parsedJson){
          var list = parsedJson['users'] as List;
          List&lt;User&gt; usersList = list.map((i) =&gt; User.fromJson(i)).toList();
          return Users(
              users: usersList
          );
        }
      }
  
      //below is the graphql configuration in my seperate GraphQl.dart file
      class GraphQLConfiguration {
        static HttpLink httpLink = HttpLink(
          uri: "http://localhost:7474/graphql/",
          headers: {
            HttpHeaders.authorizationHeader: ************",
          },
        );
        static final AuthLink authLink = AuthLink(
          getToken: () async =&gt; 'Bearer &lt;YOUR_PERSONAL_ACCESS_TOKEN&gt;',
          // OR
          // getToken: () =&gt; 'Bearer &lt;YOUR_PERSONAL_ACCESS_TOKEN&gt;',
        );
  
  
        static ValueNotifier&lt;GraphQLClient&gt; initailizeClient() {
          ValueNotifier&lt;GraphQLClient&gt; client = ValueNotifier(
            GraphQLClient(
              cache: InMemoryCache(),
              link: httpLink,
            ),
          );
          return client;
        }
  
        static GraphQLClient clientToQuery() {
          return GraphQLClient(
            cache: OptimisticCache(
                dataIdFromObject: typenameDataIdFromObject),
            link: httpLink,
          );
        }
      }
  
      //below is my main.dart file where am trying to parse the response
  
  
      void main() =&gt; runApp(MyApp());
  
      class MyApp extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
          return MaterialApp(
            debugShowCheckedModeBanner: true,
            title: 'Flutter Graphql Client',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            initialRoute: '/',
            routes: &lt;String, WidgetBuilder&gt;{
              '/': (context) =&gt; MyHomePage(), //RootPage(auth: new Auth(),),
            },
          );
        }
      }
  
      class MyHomePage extends StatefulWidget {
        @override
        _MyHomePageState createState() =&gt; _MyHomePageState();
      }
  
      class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
        Widget listViewWidget(List&lt;Users&gt; users) {
          return MediaQuery.removePadding(
            context: context, removeTop: true,
            child:  ListView.builder(
                itemCount: users.length,
                itemBuilder: (context, index) {
                  return Container(
                    child: Column(
                      children: &lt;Widget&gt;[
                        Text('users:$users'),
  
  
                      ],
                    ),
                  );
                }),
  
          );
        }
  
        String readUser = """
        query{
          User(userId:1){
            userId
            city
            country
            captionType
             state
            firstName
             lastname
            email
  
          }
        }   
  
  
        """;
  
  
        @override
        Widget build(BuildContext context) {
          return GraphQLProvider(
           client: GraphQLConfiguration.initailizeClient(),
              child: CacheProvider(
                child: Scaffold(
                  appBar: AppBar(
                    title: Text('Flutter Graphql Client'),
                  ),
                  body:Query(
                    options: QueryOptions(
                        document: readUser),
                    builder: (QueryResult result, {VoidCallback refetch, FetchMore fetchMore}) {
                      if (result.errors!= null) {
                        print('$result.errors');
                       return Text(result.errors.toString());
  
                      } if (result.errors== null){
                        print(('$result'));
                        print(('${result.data}'));
  
  
                      } if (result.loading){
                        return Center(
                            child: CupertinoActivityIndicator(
                              radius: 13.0,
                            ));
                      }
  
                        return listViewWidget(result.data);
                    },
                  )
  
                  floatingActionButton: FloatingActionButton(
                    onPressed: () {},
                    child: Icon(Icons.add),
                  ),
                ),
              ));
        }
      }
  
  </code></pre>
  
  <p>I am expecting the info to be parsed through the Users class and displayed through the listViewWidget. However I am getting'LinkHashMap is not a subtype of Users Map.'</p>