diff --git a/packages/api-cardano-db-hasura/src/executableSchema.ts b/packages/api-cardano-db-hasura/src/executableSchema.ts index 9227e496..45b570d7 100644 --- a/packages/api-cardano-db-hasura/src/executableSchema.ts +++ b/packages/api-cardano-db-hasura/src/executableSchema.ts @@ -11,7 +11,7 @@ import { GraphQLSchema } from 'graphql' import { IPv4Resolver, IPv6Resolver, - JSONObjectResolver, + JSONResolver, TimestampResolver, URLResolver } from 'graphql-scalars' @@ -24,7 +24,7 @@ export const scalarResolvers = { Hash32Hex: util.scalars.Hash32Hex, IPv4: IPv4Resolver, IPv6: IPv6Resolver, - JSONObject: JSONObjectResolver, + JSONObject: JSONResolver, Percentage: util.scalars.Percentage, StakeAddress: util.scalars.StakeAddress, StakePoolID: util.scalars.StakePoolID, diff --git a/packages/api-cardano-db-hasura/test/__snapshots__/transactions.query.test.ts.snap b/packages/api-cardano-db-hasura/test/__snapshots__/transactions.query.test.ts.snap index 7b7648db..aa0a86db 100644 --- a/packages/api-cardano-db-hasura/test/__snapshots__/transactions.query.test.ts.snap +++ b/packages/api-cardano-db-hasura/test/__snapshots__/transactions.query.test.ts.snap @@ -105,54 +105,6 @@ Object { } `; -exports[`transactions Can return transaction metadata if present 1`] = ` -Object { - "transactions": Array [ - Object { - "metadata": Array [ - Object { - "key": "0", - "value": Object { - "La_RepsistancE": "Was here", - }, - }, - Object { - "key": "1", - "value": Object { - "Choices": Array [ - Object { - "CandidateId": "aaa9503a-6fc5-46ea-9aa0-b4c90f361a4c", - "VoteRank": 1, - "VoteWeight": 1, - }, - Object { - "CandidateId": "8d649c12-936e-46be-b65a-c17f30f59574", - "VoteRank": 2, - "VoteWeight": 1, - }, - Object { - "CandidateId": "81ce7f8e-94c3-4835-91fc-2146d51fa1fc", - "VoteRank": 0, - "VoteWeight": 0, - }, - Object { - "CandidateId": "407540aa-58b5-40ca-b484-f40040eb2990", - "VoteRank": 3, - "VoteWeight": 1, - }, - ], - "NetworkId": "TheRealAdamDean", - "ObjectType": "VoteBallot", - "ProposalId": "80064c28-1b03-4f1c-abf0-ca8c5a98d5b9", - "VoterId": "d990a1e8-cb90-4f59-b5cf-a8b59c9ba8ae", - }, - }, - ], - }, - ], -} -`; - exports[`transactions Returns transactions by hashes 1`] = ` Object { "transactions": Array [ @@ -315,3 +267,94 @@ Object { ], } `; + +exports[`transactions metadata JSON object 1`] = ` +Object { + "transactions": Array [ + Object { + "metadata": Array [ + Object { + "key": "0", + "value": Object { + "La_RepsistancE": "Was here", + }, + }, + Object { + "key": "1", + "value": Object { + "Choices": Array [ + Object { + "CandidateId": "aaa9503a-6fc5-46ea-9aa0-b4c90f361a4c", + "VoteRank": 1, + "VoteWeight": 1, + }, + Object { + "CandidateId": "8d649c12-936e-46be-b65a-c17f30f59574", + "VoteRank": 2, + "VoteWeight": 1, + }, + Object { + "CandidateId": "81ce7f8e-94c3-4835-91fc-2146d51fa1fc", + "VoteRank": 0, + "VoteWeight": 0, + }, + Object { + "CandidateId": "407540aa-58b5-40ca-b484-f40040eb2990", + "VoteRank": 3, + "VoteWeight": 1, + }, + ], + "NetworkId": "TheRealAdamDean", + "ObjectType": "VoteBallot", + "ProposalId": "80064c28-1b03-4f1c-abf0-ca8c5a98d5b9", + "VoterId": "d990a1e8-cb90-4f59-b5cf-a8b59c9ba8ae", + }, + }, + ], + }, + ], +} +`; + +exports[`transactions metadata JSON string 1`] = ` +Object { + "transactions": Array [ + Object { + "metadata": Array [ + Object { + "key": "0", + "value": "MelDemo1", + }, + Object { + "key": "1", + "value": "454654654564564654", + }, + Object { + "key": "2", + "value": "sha256", + }, + Object { + "key": "3", + "value": "http://127.0.0.1/data.json", + }, + Object { + "key": "4", + "value": "dsfgdfsgsdfgsdfgsdfgdsfdfgdsfgdfgdfsgsdef", + }, + Object { + "key": "5", + "value": "http://127.0.0.1/client_publickey.txt", + }, + Object { + "key": "6", + "value": "kjfsdhgdjiksfedhdgjksdhfgjksdfhgjklsdhf", + }, + Object { + "key": "7", + "value": "http://scantrust/server_publickey.txt", + }, + ], + }, + ], +} +`; diff --git a/packages/api-cardano-db-hasura/test/transactions.query.test.ts b/packages/api-cardano-db-hasura/test/transactions.query.test.ts index e7531279..0d9352f4 100644 --- a/packages/api-cardano-db-hasura/test/transactions.query.test.ts +++ b/packages/api-cardano-db-hasura/test/transactions.query.test.ts @@ -117,11 +117,22 @@ describe('transactions', () => { }) expect(result.data).toMatchSnapshot() }) - it('Can return transaction metadata if present', async () => { - const result = await client.query({ - query: await loadQueryNode('transactionByIdWithMetadataIfPresent'), - variables: { hash: 'f910021138e553c65b96cf3e4647927fcd9f634e06544251f83cffb1891876e8' } + + describe('metadata', () => { + it('JSON object', async () => { + const result = await client.query({ + query: await loadQueryNode('transactionByIdWithMetadataIfPresent'), + variables: { hash: 'f910021138e553c65b96cf3e4647927fcd9f634e06544251f83cffb1891876e8' } + }) + expect(result.data).toMatchSnapshot() + }) + + it('JSON string', async () => { + const result = await client.query({ + query: await loadQueryNode('transactionByIdWithMetadataIfPresent'), + variables: { hash: '204ca3088bbab666692f39dddb9b773e6fb20b0d0c3e464407985fa7863e5bac' } + }) + expect(result.data).toMatchSnapshot() }) - expect(result.data).toMatchSnapshot() }) })