github.com/weaviate/weaviate@v1.24.6/adapters/handlers/graphql/local/get/sort_argument.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package get
    13  
    14  import (
    15  	"fmt"
    16  
    17  	"github.com/tailor-inc/graphql"
    18  	"github.com/weaviate/weaviate/adapters/handlers/graphql/descriptions"
    19  )
    20  
    21  func sortArgument(className string) *graphql.ArgumentConfig {
    22  	prefix := fmt.Sprintf("GetObjects%s", className)
    23  	return &graphql.ArgumentConfig{
    24  		Type: graphql.NewList(
    25  			graphql.NewInputObject(
    26  				graphql.InputObjectConfig{
    27  					Name:        fmt.Sprintf("%sSortInpObj", prefix),
    28  					Fields:      sortFields(prefix),
    29  					Description: descriptions.GetWhereInpObj,
    30  				},
    31  			),
    32  		),
    33  	}
    34  }
    35  
    36  func sortFields(prefix string) graphql.InputObjectConfigFieldMap {
    37  	return graphql.InputObjectConfigFieldMap{
    38  		"path": &graphql.InputObjectFieldConfig{
    39  			Description: descriptions.SortPath,
    40  			Type:        graphql.NewList(graphql.String),
    41  		},
    42  		"order": &graphql.InputObjectFieldConfig{
    43  			Description: descriptions.SortOrder,
    44  			Type: graphql.NewEnum(graphql.EnumConfig{
    45  				Name: fmt.Sprintf("%sSortInpObjTypeEnum", prefix),
    46  				Values: graphql.EnumValueConfigMap{
    47  					"asc":  &graphql.EnumValueConfig{},
    48  					"desc": &graphql.EnumValueConfig{},
    49  				},
    50  			}),
    51  		},
    52  	}
    53  }