diff --git a/src/types/actions.js b/src/types/actions.js new file mode 100644 index 00000000..a9001a5e --- /dev/null +++ b/src/types/actions.js @@ -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! + } +` \ No newline at end of file diff --git a/src/types/events.js b/src/types/events.js new file mode 100644 index 00000000..f3233087 --- /dev/null +++ b/src/types/events.js @@ -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! + } +` \ No newline at end of file