diff --git a/internal/graph/schema.resolvers.go.backup b/internal/graph/schema.resolvers.go.backup deleted file mode 100644 index b8bd422..0000000 --- a/internal/graph/schema.resolvers.go.backup +++ /dev/null @@ -1,82 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.36 - -import ( - "context" - - "exusiai.dev/roguestats-backend/internal/cursorutils" - "exusiai.dev/roguestats-backend/internal/ent" -) - -// Node is the resolver for the node field. -func (r *queryResolver) Node(ctx context.Context, id string) (ent.Noder, error) { - return r.Ent.Noder(ctx, id) -} - -// Nodes is the resolver for the nodes field. -func (r *queryResolver) Nodes(ctx context.Context, ids []string) ([]ent.Noder, error) { - return r.Ent.Noders(ctx, ids) -} - -// Events is the resolver for the events field. -func (r *queryResolver) Events(ctx context.Context) ([]*ent.Event, error) { - var decodedCursor string - var err error - if after != nil { - decodedCursor, err = cursorutils.DecodeCursor(*after) - if err != nil { - return nil, err - } - } - return r.EventService.GetPaginatedEvents(ctx, *researchID, *first, decodedCursor) -} - -// Researches is the resolver for the researches field. -func (r *queryResolver) Researches(ctx context.Context) ([]*ent.Research, error) { - return r.ResearchService.GetAllResearch(ctx) -} - -// Query returns QueryResolver implementation. -func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } - -type queryResolver struct{ *Resolver } - -// !!! WARNING !!! -// The code below was going to be deleted when updating resolvers. It has been copied here so you have -// one last chance to move it out of harms way if you want. There are two reasons this happens: -// - When renaming or deleting a resolver the old code will be put in here. You can safely delete -// it when you're done. -// - You have helper methods in this file. Move them out to keep these resolver files clean. -func (r *mutationResolver) Login(ctx context.Context, input ent.LoginInput) (*ent.User, error) { - return r.AuthService.AuthByLoginInput(ctx, input) -} - -func (r *mutationResolver) CreateEvent(ctx context.Context, input ent.NewEvent) (*ent.Event, error) { - return r.EventService.CreateEventFromInput(ctx, &input) -} - -func (r *mutationResolver) CreateUser(ctx context.Context, input ent.CreateUserInput) (*ent.User, error) { - return r.AuthService.CreateUser(ctx, input) -} - -func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { - return r.AuthService.CurrentUser(ctx) -} - -func (r *queryResolver) Research(ctx context.Context, id string) (*ent.Research, error) { - return r.ResearchService.GetResearchByID(ctx, id) -} - -func (r *queryResolver) GroupCount(ctx context.Context, input ent.GroupCountInput) (*ent.GroupCountResult, error) { - groupCountResult, err := r.EventService.CalculateStats(ctx, input.ResearchID, input.FilterInput, input.ResultMappingInput) - if err != nil { - return nil, err - } - return groupCountResult, nil -} -func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } - -type mutationResolver struct{ *Resolver } diff --git a/schema.graphql b/schema.graphql deleted file mode 100644 index af28be8..0000000 --- a/schema.graphql +++ /dev/null @@ -1,623 +0,0 @@ -schema { - query: Query - mutation: Mutation -} - -directive @admin on FIELD_DEFINITION - -directive @authenticated on FIELD_DEFINITION - -directive @goField( - forceResolver: Boolean - name: String -) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION - -directive @goModel( - model: String - models: [String!] -) on ENUM | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION - -directive @private(userIdFieldName: String = "id") on FIELD_DEFINITION - -scalar Any - -type CategoryCount { - category: Any! - count: Int! -} - -input CreateEventInput { - content: Map! - researchID: ID! - userAgent: String! - userID: ID! -} - -input CreateUserInput { - attributes: Map - email: String! - name: String! -} - -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor - -type Event implements Node { - content: Map! - createdAt: Time! - id: ID! - research: Research! - researchID: ID! - user: User! - userAgent: String! - userID: ID! -} - -""" -A connection to a list of items. -""" -type EventConnection { - """ - A list of edges. - """ - edges: [EventEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type EventEdge { - """ - A cursor for use in pagination. - """ - cursor: Cursor! - """ - The item at the end of the edge. - """ - node: Event -} - -""" -Ordering options for Event connections -""" -input EventOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Events. - """ - field: EventOrderField! -} - -""" -Properties by which Event connections can be ordered. -""" -enum EventOrderField { - CREATED_AT - ID -} - -""" -EventWhereInput is used for filtering Event objects. -Input was generated by ent. -""" -input EventWhereInput { - and: [EventWhereInput!] - contentJsonPredicate: Map - """ - created_at field predicates - """ - createdAt: Time - createdAtGT: Time - createdAtGTE: Time - createdAtIn: [Time!] - createdAtLT: Time - createdAtLTE: Time - createdAtNEQ: Time - createdAtNotIn: [Time!] - """ - research edge predicates - """ - hasResearch: Boolean - hasResearchWith: [ResearchWhereInput!] - """ - user edge predicates - """ - hasUser: Boolean - hasUserWith: [UserWhereInput!] - """ - id field predicates - """ - id: ID - idContainsFold: ID - idEqualFold: ID - idGT: ID - idGTE: ID - idIn: [ID!] - idLT: ID - idLTE: ID - idNEQ: ID - idNotIn: [ID!] - not: EventWhereInput - or: [EventWhereInput!] -} - -input GroupCountInput { - researchId: ID! - where: EventWhereInput - resultMappingInput: String! -} - -type GroupCountResult { - results: [CategoryCount!]! - total: Int! -} - -input LoginInput { - email: String! - password: String! - turnstileResponse: String! -} - -""" -The builtin Map type -""" -scalar Map - -type Metric implements Node { - """ - The jsonpb filter to apply to the events - """ - filter: Map! - id: ID! - """ - The mapping expr to apply to the events - """ - mapping: String! - name: String! -} - -""" -A connection to a list of items. -""" -type MetricConnection { - """ - A list of edges. - """ - edges: [MetricEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type MetricEdge { - """ - A cursor for use in pagination. - """ - cursor: Cursor! - """ - The item at the end of the edge. - """ - node: Metric -} - -""" -Ordering options for Metric connections -""" -input MetricOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Metrics. - """ - field: MetricOrderField! -} - -""" -Properties by which Metric connections can be ordered. -""" -enum MetricOrderField { - ID -} - -""" -MetricWhereInput is used for filtering Metric objects. -Input was generated by ent. -""" -input MetricWhereInput { - and: [MetricWhereInput!] - """ - events edge predicates - """ - hasEvents: Boolean - hasEventsWith: [EventWhereInput!] - """ - id field predicates - """ - id: ID - idContainsFold: ID - idEqualFold: ID - idGT: ID - idGTE: ID - idIn: [ID!] - idLT: ID - idLTE: ID - idNEQ: ID - idNotIn: [ID!] - """ - mapping field predicates - """ - mapping: String - mappingContains: String - mappingContainsFold: String - mappingEqualFold: String - mappingGT: String - mappingGTE: String - mappingHasPrefix: String - mappingHasSuffix: String - mappingIn: [String!] - mappingLT: String - mappingLTE: String - mappingNEQ: String - mappingNotIn: [String!] - """ - name field predicates - """ - name: String - nameContains: String - nameContainsFold: String - nameEqualFold: String - nameGT: String - nameGTE: String - nameHasPrefix: String - nameHasSuffix: String - nameIn: [String!] - nameLT: String - nameLTE: String - nameNEQ: String - nameNotIn: [String!] - not: MetricWhereInput - or: [MetricWhereInput!] -} - -type Mutation { - createEvent(input: CreateEventInput!): Event! @authenticated - createUser(input: CreateUserInput!): User! @admin - login(input: LoginInput!): User! - requestPasswordReset(input: RequestPasswordResetInput!): Boolean! - resetPassword(input: ResetPasswordInput!): Boolean! -} - -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node - @goModel(model: "exusiai.dev/roguestats-backend/internal/ent.Noder") { - """ - The id of the object. - """ - id: ID! -} - -""" -Possible directions in which to order a list of items when provided an `orderBy` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given `orderBy` argument. - """ - ASC - """ - Specifies a descending order for a given `orderBy` argument. - """ - DESC -} - -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """ - When paginating forwards, the cursor to continue. - """ - endCursor: Cursor - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - """ - When paginating backwards, the cursor to continue. - """ - startCursor: Cursor -} - -type Query { - event(id: ID!): Event - events( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - """ - Returns the first _n_ elements from the list. - """ - first: Int - """ - Returns the last _n_ elements from the list. - """ - last: Int - """ - Ordering options for Events returned from the connection. - """ - orderBy: EventOrder - """ - Filtering options for Events returned from the connection. - """ - where: EventWhereInput - ): EventConnection! - groupCount(input: GroupCountInput!): GroupCountResult! - """ - Returns the current authenticated user. - If the user is not authenticated, this returns null. - """ - me: User - metrics( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - """ - Returns the first _n_ elements from the list. - """ - first: Int - """ - Returns the last _n_ elements from the list. - """ - last: Int - """ - Ordering options for Metrics returned from the connection. - """ - orderBy: MetricOrder - """ - Filtering options for Metrics returned from the connection. - """ - where: MetricWhereInput - ): MetricConnection! - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - research(id: ID!): Research - researches( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - """ - Returns the first _n_ elements from the list. - """ - first: Int - """ - Returns the last _n_ elements from the list. - """ - last: Int - """ - Ordering options for Researches returned from the connection. - """ - orderBy: ResearchOrder - """ - Filtering options for Researches returned from the connection. - """ - where: ResearchWhereInput - ): ResearchConnection! -} - -input RequestPasswordResetInput { - email: String! - turnstileResponse: String! -} - -type Research implements Node { - id: ID! - name: String! - schema: Any! -} - -""" -A connection to a list of items. -""" -type ResearchConnection { - """ - A list of edges. - """ - edges: [ResearchEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} - -""" -An edge in a connection. -""" -type ResearchEdge { - """ - A cursor for use in pagination. - """ - cursor: Cursor! - """ - The item at the end of the edge. - """ - node: Research -} - -""" -Ordering options for Research connections -""" -input ResearchOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Researches. - """ - field: ResearchOrderField! -} - -""" -Properties by which Research connections can be ordered. -""" -enum ResearchOrderField { - ID -} - -""" -ResearchWhereInput is used for filtering Research objects. -Input was generated by ent. -""" -input ResearchWhereInput { - and: [ResearchWhereInput!] - """ - events edge predicates - """ - hasEvents: Boolean - hasEventsWith: [EventWhereInput!] - """ - id field predicates - """ - id: ID - idContainsFold: ID - idEqualFold: ID - idGT: ID - idGTE: ID - idIn: [ID!] - idLT: ID - idLTE: ID - idNEQ: ID - idNotIn: [ID!] - """ - name field predicates - """ - name: String - nameContains: String - nameContainsFold: String - nameEqualFold: String - nameGT: String - nameGTE: String - nameHasPrefix: String - nameHasSuffix: String - nameIn: [String!] - nameLT: String - nameLTE: String - nameNEQ: String - nameNotIn: [String!] - not: ResearchWhereInput - or: [ResearchWhereInput!] -} - -input ResetPasswordInput { - password: String! - token: String! -} - -""" -The builtin Time type -""" -scalar Time - -type User implements Node { - attributes: Map @private(userIdFieldName: "id") - email: String! @private(userIdFieldName: "id") - id: ID! - name: String! -} - -""" -UserWhereInput is used for filtering User objects. -Input was generated by ent. -""" -input UserWhereInput { - and: [UserWhereInput!] - """ - events edge predicates - """ - hasEvents: Boolean - hasEventsWith: [EventWhereInput!] - """ - id field predicates - """ - id: ID - idContainsFold: ID - idEqualFold: ID - idGT: ID - idGTE: ID - idIn: [ID!] - idLT: ID - idLTE: ID - idNEQ: ID - idNotIn: [ID!] - not: UserWhereInput - or: [UserWhereInput!] -} - -scalar Void diff --git a/tools/fullschema/codegen.yml b/tools/fullschema/codegen.yml index 5c7e741..122ad8d 100644 --- a/tools/fullschema/codegen.yml +++ b/tools/fullschema/codegen.yml @@ -1,6 +1,6 @@ schema: "../../internal/graph/defs/*.graphql" generates: - ../../schema.graphql: + ../../schema.generated.graphql: plugins: - "schema-ast" config: