Skip to content

Commit

Permalink
graphqlV2: return hosts as Host and not as Organization
Browse files Browse the repository at this point in the history
  • Loading branch information
znarf committed Dec 18, 2023
1 parent 04a1ab3 commit 2760bcf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
42 changes: 21 additions & 21 deletions server/graphql/schemaV1.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ type Expense implements Transaction {
uuid: String
type: String
kind: String
amount: Int
amount: Float

Check failure on line 3429 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Expense.amount' changed type from 'Int' to 'Float'

Field 'Expense.amount' changed type from 'Int' to 'Float'
currency: String
hostCurrency: String

Expand All @@ -3443,12 +3443,12 @@ type Expense implements Transaction {
Fetch HOST_FEE transaction for retro-compatiblity.
"""
fetchHostFee: Boolean = false
): Int
): Float

"""
Fee kept by the Open Collective Platform in the lowest unit of the currency of the host (ie. in cents)
"""
platformFeeInHostCurrency: Int
platformFeeInHostCurrency: Float

Check failure on line 3451 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Expense.platformFeeInHostCurrency' changed type from 'Int' to 'Float'

Field 'Expense.platformFeeInHostCurrency' changed type from 'Int' to 'Float'

"""
Fee kept by the payment processor in the lowest unit of the currency of the host (ie. in cents)
Expand All @@ -3458,12 +3458,12 @@ type Expense implements Transaction {
Fetch PAYMENT_PROCESSOR_FEE transaction for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
): Float

"""
The amount paid in tax (for example VAT) for this transaction
"""
taxAmount: Int
taxAmount: Float

Check failure on line 3466 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Expense.taxAmount' changed type from 'Int' to 'Float'

Field 'Expense.taxAmount' changed type from 'Int' to 'Float'

"""
If taxAmount is set, this field will contain more info about the tax
Expand All @@ -3483,8 +3483,8 @@ type Expense implements Transaction {
Fetch PAYMENT_PROCESSOR_FEE transaction and integrate in calculation for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
amountInHostCurrency: Int
): Float
amountInHostCurrency: Float

Check failure on line 3487 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Expense.amountInHostCurrency' changed type from 'Int' to 'Float'

Field 'Expense.amountInHostCurrency' changed type from 'Int' to 'Float'
host: User
createdByUser: UserDetails
fromCollective: CollectiveInterface
Expand Down Expand Up @@ -3550,7 +3550,7 @@ interface Transaction {
id: Int
idV2: String
uuid: String
amount: Int
amount: Float

Check failure on line 3553 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Transaction.amount' changed type from 'Int' to 'Float'

Field 'Transaction.amount' changed type from 'Int' to 'Float'
currency: String
hostCurrency: String
hostCurrencyFxRate: Float
Expand All @@ -3568,8 +3568,8 @@ interface Transaction {
Fetch PAYMENT_PROCESSOR_FEE transaction for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
amountInHostCurrency: Int
): Float
amountInHostCurrency: Float

Check failure on line 3572 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Transaction.amountInHostCurrency' changed type from 'Int' to 'Float'

Field 'Transaction.amountInHostCurrency' changed type from 'Int' to 'Float'

"""
Fee kept by the host in the lowest unit of the currency of the host (ie. in cents)
Expand All @@ -3579,15 +3579,15 @@ interface Transaction {
Fetch HOST_FEE transaction for retro-compatibility.
"""
fetchHostFee: Boolean = false
): Int
platformFeeInHostCurrency: Int
): Float
platformFeeInHostCurrency: Float

Check failure on line 3583 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Transaction.platformFeeInHostCurrency' changed type from 'Int' to 'Float'

Field 'Transaction.platformFeeInHostCurrency' changed type from 'Int' to 'Float'
paymentProcessorFeeInHostCurrency(

Check failure on line 3584 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Transaction.paymentProcessorFeeInHostCurrency' changed type from 'Int' to 'Float'

Field 'Transaction.paymentProcessorFeeInHostCurrency' changed type from 'Int' to 'Float'
"""
Fetch PAYMENT_PROCESSOR_FEE transaction for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
taxAmount: Int
): Float
taxAmount: Float

Check failure on line 3590 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Transaction.taxAmount' changed type from 'Int' to 'Float'

Field 'Transaction.taxAmount' changed type from 'Int' to 'Float'
taxInfo: TaxInfo
createdByUser: UserDetails
host: CollectiveInterface
Expand Down Expand Up @@ -3616,7 +3616,7 @@ type Order implements Transaction {
uuid: String
type: String
kind: String
amount: Int
amount: Float

Check failure on line 3619 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Order.amount' changed type from 'Int' to 'Float'

Field 'Order.amount' changed type from 'Int' to 'Float'
currency: String
hostCurrency: String

Expand All @@ -3633,12 +3633,12 @@ type Order implements Transaction {
Fetch HOST_FEE transaction for retro-compatiblity.
"""
fetchHostFee: Boolean = false
): Int
): Float

"""
Fee kept by the Open Collective Platform in the lowest unit of the currency of the host (ie. in cents)
"""
platformFeeInHostCurrency: Int
platformFeeInHostCurrency: Float

Check failure on line 3641 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Order.platformFeeInHostCurrency' changed type from 'Int' to 'Float'

Field 'Order.platformFeeInHostCurrency' changed type from 'Int' to 'Float'

"""
Fee kept by the payment processor in the lowest unit of the currency of the host (ie. in cents)
Expand All @@ -3648,12 +3648,12 @@ type Order implements Transaction {
Fetch PAYMENT_PROCESSOR_FEE transaction for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
): Float

"""
The amount paid in tax (for example VAT) for this transaction
"""
taxAmount: Int
taxAmount: Float

Check failure on line 3656 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Order.taxAmount' changed type from 'Int' to 'Float'

Field 'Order.taxAmount' changed type from 'Int' to 'Float'

"""
If taxAmount is set, this field will contain more info about the tax
Expand All @@ -3673,8 +3673,8 @@ type Order implements Transaction {
Fetch PAYMENT_PROCESSOR_FEE transaction and integrate in calculation for retro-compatiblity.
"""
fetchPaymentProcessorFee: Boolean = false
): Int
amountInHostCurrency: Int
): Float
amountInHostCurrency: Float

Check failure on line 3677 in server/graphql/schemaV1.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v1

Field 'Order.amountInHostCurrency' changed type from 'Int' to 'Float'

Field 'Order.amountInHostCurrency' changed type from 'Int' to 'Float'
host: User
createdByUser: UserDetails
fromCollective: CollectiveInterface
Expand Down
1 change: 1 addition & 0 deletions server/graphql/schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17087,6 +17087,7 @@ input ExpenseCreateInput {

input PayoutMethodInput {
id: String
legacyId: Int

Check warning on line 17090 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Input field 'legacyId' was added to input object type 'PayoutMethodInput'

Input field 'legacyId' was added to input object type 'PayoutMethodInput'
data: JSON
name: String
isSaved: Boolean
Expand Down
3 changes: 1 addition & 2 deletions server/graphql/v2/object/Host.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export const GraphQLHost = new GraphQLObjectType({
name: 'Host',
description: 'This represents an Host account',
interfaces: () => [GraphQLAccount, GraphQLAccountWithContributions],
// Due to overlap between our Organization and Host types, we cannot use isTypeOf here
// isTypeOf: account => account.isHostAccount,
isTypeOf: collective => collective.type === 'ORGANIZATION' && collective.isHostAccount,
fields: () => {
return {
...AccountFields,
Expand Down
2 changes: 1 addition & 1 deletion server/graphql/v2/object/Organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const GraphQLOrganization = new GraphQLObjectType({
name: 'Organization',
description: 'This represents an Organization account',
interfaces: () => [GraphQLAccount, GraphQLAccountWithContributions],
isTypeOf: collective => collective.type === 'ORGANIZATION',
isTypeOf: collective => collective.type === 'ORGANIZATION' && !collective.isHostAccount,
fields: () => {
return {
...AccountFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ describe('server/graphql/v2/mutation/AccountingCategoriesMutations', () => {
const editAccountingCategoriesMutation = gqlV2/* GraphQL */ `
mutation EditAccountingCategories($account: AccountReferenceInput!, $categories: [AccountingCategoryInput!]!) {
editAccountingCategories(account: $account, categories: $categories) {
... on Organization {
host {
id
accountingCategories {
totalCount
nodes {
id
code
name
friendlyName
expensesTypes
}
... on Host {
id
accountingCategories {
totalCount
nodes {
id
code
name
friendlyName
expensesTypes
}
}
}
Expand Down Expand Up @@ -196,7 +194,7 @@ describe('server/graphql/v2/mutation/AccountingCategoriesMutations', () => {
it('edits accounting categories successfully', async () => {
const admin = await fakeUser();
const host = await fakeActiveHost({ admin });
const getNodesFromResult = result => get(result, 'data.editAccountingCategories.host.accountingCategories.nodes');
const getNodesFromResult = result => get(result, 'data.editAccountingCategories.accountingCategories.nodes');

// Host starts with no accounting categories
expect(await host.getAccountingCategories()).to.have.length(0);
Expand Down

0 comments on commit 2760bcf

Please sign in to comment.