Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Feb 29, 2024
1 parent b655f2a commit bc6d5d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions request/graphql/schema/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ func FromString(ctx context.Context, schemaString string) (
return nil, err
}

return fromAst(ctx, doc)
return fromAst(doc)
}

// fromAst parses a GQL AST into a set of collection descriptions.
func fromAst(ctx context.Context, doc *ast.Document) (
func fromAst(doc *ast.Document) (
[]client.CollectionDefinition,
error,
) {
Expand All @@ -58,15 +58,15 @@ func fromAst(ctx context.Context, doc *ast.Document) (
for _, def := range doc.Definitions {
switch defType := def.(type) {
case *ast.ObjectDefinition:
description, err := collectionFromAstDefinition(ctx, relationManager, defType)
description, err := collectionFromAstDefinition(relationManager, defType)
if err != nil {
return nil, err
}

definitions = append(definitions, description)

case *ast.InterfaceDefinition:
description, err := schemaFromAstDefinition(ctx, relationManager, defType)
description, err := schemaFromAstDefinition(relationManager, defType)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -98,7 +98,6 @@ func fromAst(ctx context.Context, doc *ast.Document) (

// collectionFromAstDefinition parses a AST object definition into a set of collection descriptions.
func collectionFromAstDefinition(
ctx context.Context,
relationManager *RelationManager,
def *ast.ObjectDefinition,
) (client.CollectionDefinition, error) {
Expand Down Expand Up @@ -164,7 +163,6 @@ func collectionFromAstDefinition(
}

func schemaFromAstDefinition(
ctx context.Context,
relationManager *RelationManager,
def *ast.InterfaceDefinition,
) (client.SchemaDescription, error) {
Expand Down
10 changes: 4 additions & 6 deletions request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (g *Generator) Generate(ctx context.Context, collections []client.Collectio
// the given CollectionDescriptions.
func (g *Generator) generate(ctx context.Context, collections []client.CollectionDefinition) ([]*gql.Object, error) {
// build base types
defs, err := g.buildTypes(ctx, collections)
defs, err := g.buildTypes(collections)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (g *Generator) generate(ctx context.Context, collections []client.Collectio
return nil, err
}

if err := g.genAggregateFields(ctx); err != nil {
if err := g.genAggregateFields(); err != nil {
return nil, err
}
// resolve types
Expand Down Expand Up @@ -403,7 +403,6 @@ func (g *Generator) createExpandedFieldList(
// Given a set of developer defined collection types
// extract and return the correct gql.Object type(s)
func (g *Generator) buildTypes(
ctx context.Context,
collections []client.CollectionDefinition,
) ([]*gql.Object, error) {
// @todo: Check for duplicate named defined types in the TypeMap
Expand Down Expand Up @@ -594,7 +593,7 @@ func (g *Generator) buildMutationInputTypes(collections []client.CollectionDefin
return nil
}

func (g *Generator) genAggregateFields(ctx context.Context) error {
func (g *Generator) genAggregateFields() error {
topLevelCountInputs := map[string]*gql.InputObject{}
topLevelNumericAggInputs := map[string]*gql.InputObject{}

Expand Down Expand Up @@ -1014,7 +1013,7 @@ func (g *Generator) GenerateQueryInputForGQLType(
types.groupBy = g.genTypeFieldsEnum(obj)
types.order = g.genTypeOrderArgInput(obj)

queryField := g.genTypeQueryableFieldList(ctx, obj, types)
queryField := g.genTypeQueryableFieldList(obj, types)

return queryField, nil
}
Expand Down Expand Up @@ -1249,7 +1248,6 @@ type queryInputTypeConfig struct {
}

func (g *Generator) genTypeQueryableFieldList(
ctx context.Context,
obj *gql.Object,
config queryInputTypeConfig,
) *gql.Field {
Expand Down

0 comments on commit bc6d5d6

Please sign in to comment.