Skip to content

Commit

Permalink
feat(2739): review updates and suggestions from Blair.
Browse files Browse the repository at this point in the history
  • Loading branch information
koekiebox committed Jun 5, 2024
1 parent ad3f3bf commit 695e119
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
meta {
name: Get Wallet Address Additional Properties
type: graphql
seq: 21
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetWalletAddressAdditionalProperties {
additionalProperties {
properties {
key
value
visibleInOpenPayments
}
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ body:graphql {
}
}
status
additionalProperties {
properties {
key
value
visibleInOpenPayments
}
}
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 30 additions & 25 deletions packages/backend/src/graphql/generated/graphql.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions packages/backend/src/graphql/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/backend/src/graphql/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
getWalletAddressKeys,
revokeWalletAddressKey
} from './walletAddressKey'
import { getWalletAddressAdditionalProperties } from './walletAddressAdditionalProperties'
import { createReceiver, getReceiver } from './receiver'
import { getWebhookEvents } from './webhooks'
import { setFee } from './fee'
Expand Down Expand Up @@ -88,7 +89,8 @@ export const resolvers: Resolvers = {
quote: getQuote,
webhookEvents: getWebhookEvents,
payments: getCombinedPayments,
receiver: getReceiver
receiver: getReceiver,
additionalProperties: getWalletAddressAdditionalProperties
},
WalletAddress: {
liquidity: getWalletAddressLiquidity,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
ResolversTypes,
AdditionalProperty,
QueryResolvers
} from '../generated/graphql'
import { ApolloContext } from '../../app'
import { WalletAddressAdditionalProperty } from '../../open_payments/wallet_address/additional_property/model'

export const getWalletAddressAdditionalProperties: QueryResolvers<ApolloContext>['additionalProperties'] =
async (
parent,
args,
ctx
): Promise<ResolversTypes['AdditionalPropertyConnection']> => {
if (!args.walletAddressId) {
throw new Error('missing wallet address id')
}
const walletAddressService = await ctx.container.use('walletAddressService')
const additionalProperties =
await walletAddressService.getAdditionalProperties(
args.walletAddressId,
false // Include all Additional Properties
)
if (!additionalProperties) return { properties: [] }

return {
properties: additionalProperties.map((itm) =>
additionalPropertyToGraphql(itm)
)
}
}

export const additionalPropertyToGraphql = (
addProp: WalletAddressAdditionalProperty
): AdditionalProperty => ({
key: addProp.fieldKey,
value: addProp.fieldValue,
visibleInOpenPayments: addProp.visibleInOpenPayments
})
44 changes: 10 additions & 34 deletions packages/backend/src/graphql/resolvers/wallet_address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
WalletAddress,
WalletAddressStatus,
UpdateWalletAddressMutationResponse,
WalletAddressesConnection
WalletAddressesConnection,
AdditionalPropertyConnection
} from '../generated/graphql'
import { getPageTests } from './page.test'
import { WalletAddressAdditionalProperty } from '../../open_payments/wallet_address/additional_property/model'
Expand Down Expand Up @@ -510,26 +511,12 @@ describe('Wallet Address Resolvers', (): void => {
const queryAddProps = await appContainer.apolloClient
.query({
query: gql`
query WalletAddress($walletAddressId: String!) {
walletAddress(
id: $walletAddressId
includeAdditionalProperties: true
) {
id
liquidity
asset {
code
scale
}
url
publicName
status
additionalProperties {
properties {
key
value
visibleInOpenPayments
}
query Query($walletAddressId: String!) {
additionalProperties(walletAddressId: $walletAddressId) {
properties {
key
value
visibleInOpenPayments
}
}
}
Expand All @@ -538,26 +525,15 @@ describe('Wallet Address Resolvers', (): void => {
walletAddressId: walletAddress.id
}
})
.then((query): WalletAddress => {
.then((query): AdditionalPropertyConnection => {
if (query.data) {
return query.data.walletAddress
return query.data
} else {
throw new Error('Data was empty')
}
})

expect(queryAddProps).toEqual({
__typename: 'WalletAddress',
id: walletAddress.id,
liquidity: '0',
asset: {
__typename: 'Asset',
code: walletAddress.asset.code,
scale: walletAddress.asset.scale
},
url: walletAddress.url,
publicName: publicName ?? null,
status: WalletAddressStatus.Active,
additionalProperties: {
__typename: 'AdditionalPropertyConnection',
properties: [
Expand Down
Loading

0 comments on commit 695e119

Please sign in to comment.