Skip to content

Commit

Permalink
Remove properties from billable metric mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed Mar 24, 2022
1 parent d94aee7 commit c50af28
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 84 deletions.
1 change: 0 additions & 1 deletion app/graphql/mutations/billable_metrics/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Create < BaseMutation
argument :code, String, required: true
argument :description, String
argument :aggregation_type, Types::BillableMetrics::AggregationTypeEnum, required: true
argument :properties, GraphQL::Types::JSON

type Types::BillableMetrics::Object

Expand Down
1 change: 0 additions & 1 deletion app/graphql/mutations/billable_metrics/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Update < BaseMutation
argument :code, String, required: true
argument :description, String
argument :aggregation_type, Types::BillableMetrics::AggregationTypeEnum, required: true
argument :properties, GraphQL::Types::JSON

type Types::BillableMetrics::Object

Expand Down
1 change: 0 additions & 1 deletion app/graphql/types/billable_metrics/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Object < Types::BaseObject
field :code, String, null: false
field :description, String
field :aggregation_type, Types::BillableMetrics::AggregationTypeEnum, null: false
field :properties, GraphQL::Types::JSON

field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
Expand Down
4 changes: 1 addition & 3 deletions app/services/billable_metrics_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def create(**args)
name: args[:name],
code: args[:code],
description: args[:description],
aggregation_type: args[:aggregation_type]&.to_sym,
properties: args[:properties]
aggregation_type: args[:aggregation_type]&.to_sym
)

# TODO: better handling of validation errors
Expand All @@ -31,7 +30,6 @@ def update(**args)
metric.code = args[:code]
metric.description = args[:description] if args[:description]
metric.aggregation_type = args[:aggregation_type]&.to_sym
metric.properties = args[:properties] if args[:properties]

# TODO: better handling of validation errors
metric.save!
Expand Down
8 changes: 0 additions & 8 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type BillableMetric {
id: ID!
name: String!
organization: Organization
properties: JSON
updatedAt: ISO8601DateTime!
}

Expand Down Expand Up @@ -49,7 +48,6 @@ input CreateBillableMetricInput {
description: String!
name: String!
organizationId: String!
properties: JSON!
}

"""
Expand Down Expand Up @@ -142,11 +140,6 @@ An ISO 8601-encoded datetime
"""
scalar ISO8601DateTime

"""
Represents untyped JSON
"""
scalar JSON

type LoginUser {
token: String!
user: User!
Expand Down Expand Up @@ -306,7 +299,6 @@ input UpdateBillableMetricInput {
description: String!
id: String!
name: String!
properties: JSON!
}

"""
Expand Down
56 changes: 0 additions & 56 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,6 @@

]
},
{
"name": "properties",
"description": null,
"type": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null,
"args": [

]
},
{
"name": "updatedAt",
"description": null,
Expand Down Expand Up @@ -487,22 +473,6 @@
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "properties",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"enumValues": null
Expand Down Expand Up @@ -970,16 +940,6 @@
"inputFields": null,
"enumValues": null
},
{
"kind": "SCALAR",
"name": "JSON",
"description": "Represents untyped JSON",
"interfaces": null,
"possibleTypes": null,
"fields": null,
"inputFields": null,
"enumValues": null
},
{
"kind": "OBJECT",
"name": "LoginUser",
Expand Down Expand Up @@ -2255,22 +2215,6 @@
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "properties",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"enumValues": null
Expand Down
6 changes: 2 additions & 4 deletions spec/graphql/mutations/billable_metrics/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
code: 'new_metric',
description: 'New metric description',
organizationId: membership.organization_id,
aggregationType: 'count_agg',
properties: {}
aggregationType: 'count_agg'
}
}
)
Expand All @@ -55,8 +54,7 @@
code: 'new_metric',
description: 'New metric description',
organizationId: membership.organization_id,
aggregationType: 'count_agg',
properties: {}
aggregationType: 'count_agg'
}
}
)
Expand Down
6 changes: 2 additions & 4 deletions spec/graphql/mutations/billable_metrics/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
name: 'New Metric',
code: 'new_metric',
description: 'New metric description',
aggregationType: 'count_agg',
properties: {}
aggregationType: 'count_agg'
}
}
)
Expand All @@ -56,8 +55,7 @@
name: 'New Metric',
code: 'new_metric',
description: 'New metric description',
aggregationType: 'count_agg',
properties: {}
aggregationType: 'count_agg'
}
}
)
Expand Down
9 changes: 3 additions & 6 deletions spec/services/billable_metrics_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
code: 'new_metric',
description: 'New metric description',
organization_id: organization.id,
aggregation_type: 'count_agg',
properties: {}
aggregation_type: 'count_agg'
}
end

Expand Down Expand Up @@ -60,8 +59,7 @@
name: 'New Metric',
code: 'new_metric',
description: 'New metric description',
aggregation_type: 'count_agg',
properties: {}
aggregation_type: 'count_agg'
}
end

Expand All @@ -86,8 +84,7 @@
name: nil,
code: 'new_metric',
description: 'New metric description',
aggregation_type: 'count_agg',
properties: {}
aggregation_type: 'count_agg'
}
end

Expand Down

0 comments on commit c50af28

Please sign in to comment.