Spring Boot GraphQL groupBy и orderBy не работают - PullRequest
0 голосов
/ 25 апреля 2019

Я хочу получить результат ранжирования с помощью graphQL

Предыдущий запрос похож на

select * from view_user_account_point group by totalPoint, userId order by totalPoint

Через итоговый балл я хочу получить результат системы ранжирования и порядок по нумерации какЧто ж.Однако я не делаю запрос, как использование group By и order By.

schema{
query:Query
}


type Query{
    AllViewPoints:[ViewUserAccountPoint]
    ViewPointByUserId(userAccountPointUserId:Int) : [ViewUserAccountPoint]

    }



type ViewUserAccountPoint{
 rowNum:Long
 userAccountPointUserId:Int
 subjectId:Int
 point:Int
userAccountPointTypeId:Int
userAccountCreatedDate:String
userAccountPointStudyId:Int
userAccountUserName:String
userAccountOwnerId:Int
userAccountStatusId:Int
pointTypeId:Int
pointTypeName:String
pointTypeDescription:String
levelUserId:Int
levelLogTypeId:Int
registeredDate:String
levelTypeId:Int
levelTypeName:String
levelTypeDescription:String
userLevelTypeUserRoleId:Int
creationRightNum:Int
levelStartPoint:Int
levelEndPoint:Int
 levelTypeOwnerId:Int
studyName:String
studyStatusId:Int
userAccountRoleId:Int
userAccountRoleName:String
userAccountWalletUserId:Int
totalPoint:Int
steemitPoint:Int
lastUpdatedTimestamp:String

    }

Grapql.service

@Value("classpath:userAccountPoint.graphqls")
    Resource resource;

    private GraphQL graphQL;

    @Autowired
    private AllViewPointsDataFetcher allViewPointsDataFetcher;

    @Autowired
    private ViewPointByUserIdDataFetcher viewPointsByUserIdDataFetcher;

    //load schema at application start up
    @PostConstruct
    private void loadSchema() throws IOException {
        File schemaFile = resource.getFile();
        TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(schemaFile);
        RuntimeWiring wiring = buildRuntimeWiring();
        GraphQLSchema schema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
        graphQL = GraphQL.newGraphQL(schema).build();
    }

    private RuntimeWiring buildRuntimeWiring() {
        return RuntimeWiring.newRuntimeWiring()
                .type("Query", typeWiring -> typeWiring
                        .dataFetcher("AllViewPoints", allViewPointsDataFetcher)
                        .dataFetcher("ViewPointByUserId", viewPointsByUserIdDataFetcher))

                .build();
    }

    public GraphQL getGraphQL() {
        return graphQL;
    }

GraphQL.controller

@RestController
@RequestMapping("/restapi/graphql")
public class GraphQLController {

    @Autowired
    GraphQLService graphQLService;

    @PostMapping
    public ResponseEntity<Object> getAllStudyComments(@RequestBody String query) {
        ExecutionResult executionResult = graphQLService.getGraphQL().execute(query);

        return new ResponseEntity<>(executionResult, HttpStatus.OK);
    }

Более того, есть репозиторий.

Запрос использования сортировки groupBy и orderBy невозможен в GraphQL?если это возможно, пожалуйста, дайте мне знать, как это сделать.

...