Skip to content

Commit

Permalink
Expose trialed and trialUntil (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Jul 5, 2023
1 parent c94c04c commit bdc44c0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/graphql/lib/graphql/schema/account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ defmodule GraphQl.Schema.Account do
field :delinquent_at, :datetime
field :grandfathered_until, :datetime
field :billing_address, :address
field :trialed, :boolean

field :icon, :string, resolve: fn
account, _, _ -> {:ok, Core.Storage.url({account.icon, account}, :original)}
Expand Down
7 changes: 7 additions & 0 deletions apps/graphql/lib/graphql/schema/payments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,16 @@ defmodule GraphQl.Schema.Payments do
field :external_id, :string
field :line_items, list_of(:platform_subscription_line_items)
field :plan, :platform_plan, resolve: dataloader(Payments)

field :trial_until, :datetime, resolve: fn
%{inserted_at: dt}, _, _ -> {:ok, Timex.shift(dt, months: 1)}
end

field :latest_invoice, :invoice, resolve: fn
sub, _, _ -> Payments.latest_invoice(sub)
end

timestamps()
end

object :platform_subscription_line_items do
Expand Down
5 changes: 4 additions & 1 deletion apps/graphql/test/queries/payments_queries_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ defmodule GraphQl.PaymentsQueriesTest do

{:ok, %{data: %{"platformSubscription" => found}}} = run_query("""
query {
platformSubscription { id }
platformSubscription {
id
trialUntil
}
}
""", %{}, %{current_user: user})

Expand Down
4 changes: 4 additions & 0 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ type Account {
delinquentAt: DateTime
grandfatheredUntil: DateTime
billingAddress: Address
trialed: Boolean
icon: String
paymentMethods(after: String, first: Int, before: String, last: Int): PaymentMethodConnection
rootUser: User
Expand Down Expand Up @@ -837,7 +838,10 @@ type PlatformSubscription {
externalId: String
lineItems: [PlatformSubscriptionLineItems]
plan: PlatformPlan
trialUntil: DateTime
latestInvoice: Invoice
insertedAt: DateTime
updatedAt: DateTime
}

type PaymentMethodConnection {
Expand Down
4 changes: 4 additions & 0 deletions www/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type Account = {
paymentMethods?: Maybe<PaymentMethodConnection>;
rootUser?: Maybe<User>;
subscription?: Maybe<PlatformSubscription>;
trialed?: Maybe<Scalars['Boolean']['output']>;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
userCount?: Maybe<Scalars['String']['output']>;
workosConnectionId?: Maybe<Scalars['String']['output']>;
Expand Down Expand Up @@ -2051,9 +2052,12 @@ export type PlatformSubscription = {
__typename?: 'PlatformSubscription';
externalId?: Maybe<Scalars['String']['output']>;
id: Scalars['ID']['output'];
insertedAt?: Maybe<Scalars['DateTime']['output']>;
latestInvoice?: Maybe<Invoice>;
lineItems?: Maybe<Array<Maybe<PlatformSubscriptionLineItems>>>;
plan?: Maybe<PlatformPlan>;
trialUntil?: Maybe<Scalars['DateTime']['output']>;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
};

export type PlatformSubscriptionLineItems = {
Expand Down

0 comments on commit bdc44c0

Please sign in to comment.