investigate issue
MODIFY
packages/graphql/test/graphql_client_test.dart
packages/graphql/test/graphql_client_test.dart
@@ -154,6 +154,333 @@ void main() {
equals('bar'),
);
});
+ test('issue 1208', () async {
+ final client = GraphQLClient(
+ cache: GraphQLCache(
+ possibleTypes: {
+ 'WalletContentBlock': {'WalletContentBlockList'},
+ 'WalletContentItem': {'WalletContentItemContentPreview'}
+ },
+ ),
+ link: link,
+ );
+ const data = {
+ "__typename": "Query",
+ "walletGetContent": {
+ "__typename": "WalletGetContentPayload",
+ "blocks": [
+ {
+ "__typename": "WalletContentBlockList",
+ "id": "1",
+ "blockType": {
+ "__typename": "WalletContentBlockType",
+ "id": "horizontal-scrolling-list",
+ },
+ "caption": "Featured",
+ "items": [
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "1",
+ "caption": "Remarkable Women #4740",
+ "imageURL":
+ "https://lh3.googleusercontent.com/1kXncBpOzPjZAC46GDNXvW4NL0zDv1e_E6vzsTtKEAOAvb0SwbWzwljDY5hulMqRA4zQytjYjV7B-a_jYtNG6zy9dKssov9RRRLu5ss=w600",
+ "link":
+ "https://opensea.io/assets/ethereum/0x3e69baab7a742c83499661c5db92386b2424df11/4740"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "2",
+ "caption": "Inftspaces",
+ "imageURL":
+ "https://lh3.googleusercontent.com/8h6WQ4_Kxn0c6rBujSe0flZMTSKiWGWiMOSNaSTPUchakVq4TmyBOWJi4E0GU3_5b7v4jF-vIPR24uziltXMfQHgzEj3zBCkW_Tbsw=s0",
+ "link":
+ "https://opensea.io/assets/ethereum/0xb11288c7237765db4782dfddcc49e31bb80132b8/90"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "3",
+ "caption": "Love on Mars",
+ "imageURL":
+ "https://lh3.googleusercontent.com/XoOJwf3DQ6ZWMpmmLkVqfZD3AqEM3G0xQCXNur0-u5-HAHpoMHyPJQL__5H0wpJsy2cafaaCSSxI5YPjnzCZ-4ME7hnJXrgd5292nA=s0",
+ "link":
+ "https://opensea.io/collection/love-on-mars-by-ruben-rojas-x-omgdrops"
+ }
+ ]
+ },
+ {
+ "__typename": "WalletContentBlockList",
+ "id": "2",
+ "blockType": {
+ "__typename": "WalletContentBlockType",
+ "id": "vertical-short-list"
+ },
+ "caption": "New",
+ "items": [
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "4",
+ "caption": "MSO LAB Genesis #844",
+ "imageURL":
+ "https://lh3.googleusercontent.com/FCcSKSsYaNk9-bzks7ZWIEjFPiL8xrtb8aYnO2DG0piF9Eja1AkY55Yan-KQqtpcwISdpTWNz_W0yrmmmQM2hAHNG_AIXl7E4ATG2Q=w600",
+ "link":
+ "https://opensea.io/assets/ethereum/0xc2ac394984f3850027dac95fe8a62e446c5fb786/844"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "5",
+ "caption": "The Outsiders Genesis",
+ "imageURL":
+ "https://lh3.googleusercontent.com/AM8EkaQl32uR8N1RIiJa5ogVG1gh2faX6u4a1TAa_NhsGkA2CRG0pFfMOOxcc09q2KFq5cQNljTFkDbbScWpUT70es83Di0RRWD7fjM=s0",
+ "link":
+ "https://opensea.io/collection/the-outsiders-genesis"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "6",
+ "caption": "Bored Ape Yacht Club #6386",
+ "imageURL":
+ "https://img.seadn.io/files/968a4be8ada4a55b59de561d15522b4e.png?fit=max&w=600",
+ "link":
+ "https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/6386"
+ }
+ ]
+ }
+ ]
+ }
+ };
+ final _options = QueryOptions(
+ document: parseString(r'''
+query WalletGetContent($input: WalletGetContentInput!) {
+ __typename
+ walletGetContent(input: $input) {
+ __typename
+ blocks {
+ __typename
+ ... on WalletContentBlockList {
+ __typename
+ id
+ blockType {
+ __typename
+ id
+ }
+ caption
+ items {
+ __typename
+ ... on WalletContentItemContentPreview {
+ __typename
+ id
+ caption
+ imageURL
+ link
+ }
+ }
+ }
+ }
+ }
+}
+'''),
+ variables: <String, dynamic>{
+ 'input': {'id': 'foo'},
+ },
+ );
+
+ when(
+ link.request(any),
+ ).thenAnswer(
+ (_) => Stream.fromIterable([
+ Response(
+ data: data,
+ context: Context().withEntry(
+ HttpLinkResponseContext(
+ statusCode: 200,
+ headers: {'foo': 'bar'},
+ ),
+ ),
+ response: {},
+ ),
+ ]),
+ );
+
+ final QueryResult r = await client.query(_options);
+ expect(r.exception, isNull);
+ expect(r.data, equals(data));
+ });
+ test('issue 1208, duplicate IDs', () async {
+ final client = GraphQLClient(
+ cache: GraphQLCache(
+ possibleTypes: {
+ 'WalletContentBlock': {'WalletContentBlockList'},
+ 'WalletContentItem': {'WalletContentItemContentPreview'}
+ },
+ ),
+ link: link,
+ );
+ const data = {
+ "__typename": "Query",
+ "walletGetContent": {
+ "__typename": "WalletGetContentPayload",
+ "blocks": [
+ {
+ "__typename": "WalletContentBlockList",
+ "id": "1",
+ "blockType": {
+ "__typename": "WalletContentBlockType",
+ "id": "horizontal-scrolling-list",
+ },
+ "caption": "Featured",
+ "items": [
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "1",
+ "caption": "Remarkable Women #4740",
+ "imageURL":
+ "https://lh3.googleusercontent.com/1kXncBpOzPjZAC46GDNXvW4NL0zDv1e_E6vzsTtKEAOAvb0SwbWzwljDY5hulMqRA4zQytjYjV7B-a_jYtNG6zy9dKssov9RRRLu5ss=w600",
+ "link":
+ "https://opensea.io/assets/ethereum/0x3e69baab7a742c83499661c5db92386b2424df11/4740"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "2",
+ "caption": "Inftspaces",
+ "imageURL":
+ "https://lh3.googleusercontent.com/8h6WQ4_Kxn0c6rBujSe0flZMTSKiWGWiMOSNaSTPUchakVq4TmyBOWJi4E0GU3_5b7v4jF-vIPR24uziltXMfQHgzEj3zBCkW_Tbsw=s0",
+ "link":
+ "https://opensea.io/assets/ethereum/0xb11288c7237765db4782dfddcc49e31bb80132b8/90"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "3",
+ "caption": "Love on Mars",
+ "imageURL":
+ "https://lh3.googleusercontent.com/XoOJwf3DQ6ZWMpmmLkVqfZD3AqEM3G0xQCXNur0-u5-HAHpoMHyPJQL__5H0wpJsy2cafaaCSSxI5YPjnzCZ-4ME7hnJXrgd5292nA=s0",
+ "link":
+ "https://opensea.io/collection/love-on-mars-by-ruben-rojas-x-omgdrops"
+ }
+ ]
+ },
+ {
+ "__typename": "WalletContentBlockList",
+ "id": "2",
+ "blockType": {
+ "__typename": "WalletContentBlockType",
+ "id": "vertical-short-list"
+ },
+ "caption": "New",
+ "items": [
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "1",
+ "caption": "MSO LAB Genesis #844",
+ "imageURL":
+ "https://lh3.googleusercontent.com/FCcSKSsYaNk9-bzks7ZWIEjFPiL8xrtb8aYnO2DG0piF9Eja1AkY55Yan-KQqtpcwISdpTWNz_W0yrmmmQM2hAHNG_AIXl7E4ATG2Q=w600",
+ "link":
+ "https://opensea.io/assets/ethereum/0xc2ac394984f3850027dac95fe8a62e446c5fb786/844"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "2",
+ "caption": "The Outsiders Genesis",
+ "imageURL":
+ "https://lh3.googleusercontent.com/AM8EkaQl32uR8N1RIiJa5ogVG1gh2faX6u4a1TAa_NhsGkA2CRG0pFfMOOxcc09q2KFq5cQNljTFkDbbScWpUT70es83Di0RRWD7fjM=s0",
+ "link":
+ "https://opensea.io/collection/the-outsiders-genesis"
+ },
+ {
+ "__typename": "WalletContentItemContentPreview",
+ "id": "3",
+ "caption": "Bored Ape Yacht Club #6386",
+ "imageURL":
+ "https://img.seadn.io/files/968a4be8ada4a55b59de561d15522b4e.png?fit=max&w=600",
+ "link":
+ "https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/6386"
+ }
+ ]
+ }
+ ]
+ }
+ };
+ final _options = QueryOptions(
+ document: parseString(r'''
+query WalletGetContent($input: WalletGetContentInput!) {
+ __typename
+ walletGetContent(input: $input) {
+ __typename
+ blocks {
+ __typename
+ ... on WalletContentBlockList {
+ __typename
+ id
+ blockType {
+ __typename
+ id
+ }
+ caption
+ items {
+ __typename
+ ... on WalletContentItemContentPreview {
+ __typename
+ id
+ caption
+ imageURL
+ link
+ }
+ }
+ }
+ }
+ }
+}
+'''),
+ variables: <String, dynamic>{
+ 'input': {'id': 'foo'},
+ },
+ );
+
+ when(
+ link.request(any),
+ ).thenAnswer(
+ (_) => Stream.fromIterable([
+ Response(
+ data: data,
+ context: Context().withEntry(
+ HttpLinkResponseContext(
+ statusCode: 200,
+ headers: {'foo': 'bar'},
+ ),
+ ),
+ response: {},
+ ),
+ ]),
+ );
+
+ final QueryResult r = await client.query(_options);
+ expect(r.exception, isNull);
+ expect(
+ r.data,
+ equals({
+ ...data,
+ "walletGetContent": {
+ ...data["walletGetContent"] as Map<String, dynamic>,
+ "blocks": [
+ {
+ ...(data["walletGetContent"]
+ as Map<String, dynamic>)["blocks"][0]
+ as Map<String, dynamic>,
+ "items": ((data["walletGetContent"]
+ as Map<String, dynamic>)["blocks"][1]
+ as Map<String, dynamic>)["items"],
+ },
+ {
+ ...(data["walletGetContent"]
+ as Map<String, dynamic>)["blocks"][1]
+ as Map<String, dynamic>,
+ "items": ((data["walletGetContent"]
+ as Map<String, dynamic>)["blocks"][1]
+ as Map<String, dynamic>)["items"],
+ }
+ ]
+ }
+ }));
+ });
test('successful response with parser', () async {
final ResultParserFn<List<String>> parserFn = (data) {

investigate issue #1208