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

feat(cascade-plan-changes): add api and GQL support for cascade feature #2726

Merged
merged 2 commits into from
Oct 31, 2024
Merged
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
1 change: 1 addition & 0 deletions app/controllers/api/v1/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def input_params
:trial_period,
:pay_in_advance,
:bill_charges_monthly,
:cascade_updates,
tax_codes: [],
minimum_commitment: [
:id,
Expand Down
1 change: 1 addition & 0 deletions app/graphql/mutations/plans/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Update < BaseMutation
argument :amount_cents, GraphQL::Types::BigInt, required: true
argument :amount_currency, Types::CurrencyEnum, required: true
argument :bill_charges_monthly, Boolean, required: false
argument :cascade_updates, Boolean, required: false
argument :code, String, required: true
argument :description, String, required: false
argument :id, String, required: true
Expand Down
6 changes: 6 additions & 0 deletions app/graphql/types/plans/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Object < Types::BaseObject
field :charges, [Types::Charges::Object]
field :taxes, [Types::Taxes::Object]

field :has_overridden_plans, Boolean

field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false

Expand All @@ -46,6 +48,10 @@ def charges_count
object.charges.count
end

def has_overridden_plans
object.children.any?
end

def subscriptions_count
count = object.subscriptions.count
return count unless object.children
Expand Down
2 changes: 2 additions & 0 deletions schema.graphql

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

26 changes: 26 additions & 0 deletions schema.json

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

1 change: 1 addition & 0 deletions spec/graphql/types/plans/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
it { is_expected.to have_field(:bill_charges_monthly).of_type('Boolean') }
it { is_expected.to have_field(:code).of_type('String!') }
it { is_expected.to have_field(:description).of_type('String') }
it { is_expected.to have_field(:has_overridden_plans).of_type('Boolean') }
it { is_expected.to have_field(:interval).of_type('PlanInterval!') }
it { is_expected.to have_field(:invoice_display_name).of_type('String') }
it { is_expected.to have_field(:minimum_commitment).of_type('Commitment') }
Expand Down