Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new GraphQL Goal object and resolver on Account.goal #10384

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions server/constants/goal-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Constants for the goal type
*
*/

enum GoalTypes {
ALL_TIME = 'ALL_TIME',
MONTHLY_BUDGET = 'MONTHLY_BUDGET',
YEARLY_BUDGET = 'YEARLY_BUDGET',
CALENDAR_MONTH = 'CALENDAR_MONTH',
CALENDAR_YEAR = 'CALENDAR_YEAR',
}

export default GoalTypes;
238 changes: 238 additions & 0 deletions server/graphql/schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0

Check notice on line 1003 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to interface 'Account'

Field 'goal' was added to interface 'Account'
forGoalType: GoalType

Check notice on line 1004 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to interface 'Account'

Field 'activeContributors' was added to interface 'Account'
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
}

"""
Expand Down Expand Up @@ -3430,6 +3446,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand All @@ -3451,8 +3483,8 @@
Type of account (COLLECTIVE/EVENT/ORGANIZATION/INDIVIDUAL)
"""
accountType: AccountType
): Int!

Check notice on line 3486 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Host'

Field 'goal' was added to object type 'Host'
tiers(

Check notice on line 3487 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Host'

Field 'activeContributors' was added to object type 'Host'
"""
The number of results to fetch
"""
Expand Down Expand Up @@ -6265,6 +6297,64 @@
expenseType: ExpenseType
}

type Goal {
"""
The type of the goal (per month, per year or all time)
"""
type: GoalType

"""
The amount of the goal
"""
amount: Amount

"""
The progress of the goal in percentage
"""
progress: Int
contributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

Check notice on line 6320 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Type 'Goal' was added

Type 'Goal' was added
"""
The offset to use to fetch
"""
offset: Int! = 0
): AccountCollection
}

"""
All supported goal types
"""
enum GoalType {
"""
Total contributions
"""
ALL_TIME

"""
Active yearly contributions (divided by 12), active monthly contributions and one-time contributions in the past 30 days
"""
MONTHLY_BUDGET

"""
Active yearly contributions , active monthly contributions (times 12) and one-time contributions in the past 365 days
"""
YEARLY_BUDGET

"""
Contributions in the current calendar month
"""
CALENDAR_MONTH

Check notice on line 6351 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Type 'GoalType' was added

Type 'GoalType' was added
"""
Contributions in the current calendar year
"""
CALENDAR_YEAR
}

"""
A collection of webhooks
"""
Expand Down Expand Up @@ -8413,6 +8503,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand All @@ -8437,8 +8543,8 @@
"""
The slug identifying the account (ie: babel)
"""
slug: String!

Check notice on line 8546 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Bot'

Field 'goal' was added to object type 'Bot'
type: AccountType!

Check notice on line 8547 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Bot'

Field 'activeContributors' was added to object type 'Bot'

"""
Public name
Expand Down Expand Up @@ -9260,6 +9366,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -9294,8 +9416,8 @@
hostApplication: HostApplication

"""
How much platform fees are charged for this account

Check notice on line 9419 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Collective'

Field 'goal' was added to object type 'Collective'
"""

Check notice on line 9420 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Collective'

Field 'activeContributors' was added to object type 'Collective'
platformFeePercent: Float!

"""
Expand Down Expand Up @@ -10560,6 +10682,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -10650,8 +10788,8 @@
contributors(
"""
The number of results to fetch (default 10, max 1000)
"""

Check notice on line 10791 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Event'

Field 'goal' was added to object type 'Event'
limit: Int! = 10

Check notice on line 10792 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Event'

Field 'activeContributors' was added to object type 'Event'

"""
The offset to use to fetch
Expand Down Expand Up @@ -11640,6 +11778,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -11756,8 +11910,8 @@

"""
The account that owns this personal token
"""

Check notice on line 11913 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Individual'

Field 'goal' was added to object type 'Individual'
account: Individual!

Check notice on line 11914 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Individual'

Field 'activeContributors' was added to object type 'Individual'

"""
The date on which the personal token was created
Expand Down Expand Up @@ -12693,6 +12847,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -12819,8 +12989,8 @@

"""
Public name
"""

Check notice on line 12992 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Organization'

Field 'goal' was added to object type 'Organization'
name: String

Check notice on line 12993 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Organization'

Field 'activeContributors' was added to object type 'Organization'

"""
Private, legal name. Used for expense receipts, taxes, etc. Scope: "account".
Expand Down Expand Up @@ -13637,6 +13807,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -13773,8 +13959,8 @@
ALL_TIME
}

"""

Check notice on line 13962 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Vendor'

Field 'goal' was added to object type 'Vendor'
A Virtual Card request

Check notice on line 13963 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Vendor'

Field 'activeContributors' was added to object type 'Vendor'
"""
type VirtualCardRequest {
id: String!
Expand Down Expand Up @@ -17213,6 +17399,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -17359,8 +17561,8 @@
name: String

"""
Private, legal name. Used for expense receipts, taxes, etc. Scope: "account".

Check notice on line 17564 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Fund'

Field 'goal' was added to object type 'Fund'
"""

Check notice on line 17565 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Fund'

Field 'activeContributors' was added to object type 'Fund'
legalName: String
description: String
longDescription: String
Expand Down Expand Up @@ -18173,6 +18375,22 @@
EXPERIMENTAL (this may change or be removed)
"""
transactionReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): TransactionReports
goal: Goal
activeContributors(
"""
The number of results to fetch (default 10, max 1000)
"""
limit: Int! = 10

"""
The offset to use to fetch
"""
offset: Int! = 0
forGoalType: GoalType
dateFrom: DateTime
dateTo: DateTime
includeActiveRecurringContributions: Boolean
): AccountCollection
webhooks(
"""
The number of results to fetch (default 10, max 1000)
Expand Down Expand Up @@ -18345,8 +18563,8 @@
Search results for Updates
"""
updates: SearchResultsUpdates
}

Check notice on line 18566 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'goal' was added to object type 'Project'

Field 'goal' was added to object type 'Project'

Check notice on line 18567 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'activeContributors' was added to object type 'Project'

Field 'activeContributors' was added to object type 'Project'
type SearchResultsAccounts {
collection: AccountCollection!
highlights: JSONObject
Expand Down Expand Up @@ -19210,6 +19428,18 @@
emailConfirmationToken: String!
): ConfirmGuestAccountResponse!

"""
Set a goal for your account.
"""
setGoal(
account: AccountReferenceInput!

"""
The goal to set for the account. Setting goal to undefined or null will remove any current goal.
"""
goal: GoalInput
): Goal

"""
Apply to an host with a collective. Scope: "account".
"""
Expand Down Expand Up @@ -19405,7 +19635,7 @@
"""
Edit an existing member invitation of the Collective. Scope: "account".
"""
editMemberInvitation(

Check notice on line 19638 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'setGoal' was added to object type 'Mutation'

Field 'setGoal' was added to object type 'Mutation'
"""
Reference to an account for the member to edit.
"""
Expand Down Expand Up @@ -21479,6 +21709,14 @@
accessToken: String!
}

"""
Input type for Goals
"""
input GoalInput {
type: GoalType!
amount: Int!
}

type ProcessHostApplicationResponse {
"""
The account that applied to the host
Expand Down Expand Up @@ -21688,7 +21926,7 @@
}

"""
Input type for guest contributions

Check notice on line 21929 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Type 'GoalInput' was added

Type 'GoalInput' was added
"""
input GuestInfoInput {
"""
Expand Down
27 changes: 27 additions & 0 deletions server/graphql/v2/enum/GoalType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { GraphQLEnumType } from 'graphql';

import goalType from '../../../constants/goal-types';

export const GraphQLGoalType = new GraphQLEnumType({
name: 'GoalType',
description: 'All supported goal types',
values: {
[goalType.ALL_TIME]: {
description: 'Total contributions',
},
[goalType.MONTHLY_BUDGET]: {
description:
'Active yearly contributions (divided by 12), active monthly contributions and one-time contributions in the past 30 days',
},
[goalType.YEARLY_BUDGET]: {
description:
'Active yearly contributions , active monthly contributions (times 12) and one-time contributions in the past 365 days',
},
[goalType.CALENDAR_MONTH]: {
description: 'Contributions in the current calendar month',
},
[goalType.CALENDAR_YEAR]: {
description: 'Contributions in the current calendar year',
},
},
});
12 changes: 12 additions & 0 deletions server/graphql/v2/input/GoalInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GraphQLInputObjectType, GraphQLInt, GraphQLNonNull } from 'graphql';

import { GraphQLGoalType } from '../enum/GoalType';

export const GraphQLGoalInput = new GraphQLInputObjectType({
name: 'GoalInput',
description: 'Input type for Goals',
fields: () => ({
type: { type: new GraphQLNonNull(GraphQLGoalType) },
amount: { type: new GraphQLNonNull(GraphQLInt) },
}),
});
Loading
Loading