Skip to content

Commit

Permalink
Event types #40
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Oct 18, 2020
1 parent 4a9ca29 commit fa7cf27
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/types/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict'

const { gql } = require('apollo-server-micro')

module.exports = gql`
"""
Event entries will be stored as actions. The TotalSumAction contains data for a TotalSum type event.
"""
type TotalSumAction {
"""
Action identifier.
"""
id: ID!
"""
Identifies the date and time when the object was created.
"""
created: DateTime!
"""
Identifies the date and time when the object was updated.
"""
updated: DateTime!
}
input CreateTotalSumActionInput {
"""
Numerical value that is added to all other numerical values of the same day, month or year.
"""
value: Float!
}
type CreateTotalSumActionPayload {
"""
Indicates that the action creation was successful. Might be 'null' otherwise.
"""
success: Boolean
"""
The newly created action.
"""
payload: TotalSumAction
}
input UpdateTotalSumActionInput {
"""
Numerical value that is added to all other numerical values of the same day, month or year.
"""
value: Float!
}
type UpdateTotalSumActionPayload {
"""
Indicates that the action update was successful. Might be 'null' otherwise.
"""
success: Boolean
"""
The updated action.
"""
payload: TotalSumAction
}
type Mutation {
"""
Create a new action for a TotalSum type event.
"""
createTotalSumAction(eventId: ID!, input: CreateTotalSumActionInput!): CreateTotalSumActionPayload!
"""
Update an existing action for a TotalSum type event.
"""
updateTotalSumAction(id: ID!, input: UpdateTotalSumActionInput!): UpdateTotalSumActionPayload!
}
`
123 changes: 123 additions & 0 deletions src/types/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
'use strict'

const { gql } = require('apollo-server-micro')

module.exports = gql`
enum EventType {
"""
Event that calculates the sum of all action values grouped by day, month or year.
"""
TOTAL_SUM
"""
Event that calculates the sum of all action values of a key, grouped by day, month or year.
"""
KEY_SUM
"""
Event that shows all actions in a chronic order.
"""
LOG
}
"""
Events are required to track actions. You can create as many events as you want. This allows you to analyse specific actions happening on your sites. Like a button click or a successful sale.
"""
type Event {
"""
Event identifier.
"""
id: ID!
"""
Title of the event.
"""
title: String!
"""
Type of the event.
"""
type: EventType!
"""
Identifies the date and time when the object was created.
"""
created: DateTime!
"""
Identifies the date and time when the object was updated.
"""
updated: DateTime!
}
input CreateEventInput {
"""
Title of the event.
"""
title: String!
"""
Type of the event.
"""
type: EventType!
}
type CreateEventPayload {
"""
Indicates that the event creation was successful. Might be 'null' otherwise.
"""
success: Boolean
"""
The newly created event.
"""
payload: Event
}
input UpdateEventInput {
"""
Title of the event.
"""
title: String!
"""
Type of the event.
"""
type: EventType!
}
type UpdateEventPayload {
"""
Indicates that the event update was successful. Might be 'null' otherwise.
"""
success: Boolean
"""
The updated event.
"""
payload: Event
}
type DeleteEventPayload {
"""
Indicates that the event deletion was successful. Might be 'null' otherwise.
"""
success: Boolean
}
type Query {
"""
Data of a specific event.
"""
event(id: ID!): Event
"""
Data of all existing events.
"""
events: [Event!]
}
type Mutation {
"""
Create a new event.
"""
createEvent(input: CreateEventInput!): CreateEventPayload!
"""
Update an existing event.
"""
updateEvent(id: ID!, input: UpdateEventInput!): UpdateEventPayload!
"""
Delete an existing event.
"""
deleteEvent(id: ID!): DeleteEventPayload!
}
`

0 comments on commit fa7cf27

Please sign in to comment.