Fixed arbitrary ordering of directions in GraphqlConfig causing error (#625)

## Description
If the user specified their orderings in their GraphqlConfig in a
different order, they would be presented with an error.

```yaml
enumTypeNames:
  - directions: # Reversed ordering of this list
      - Desc
      - Asc
    typeName: OrderBy
```

> ERR Code=opendds-validation Message="invalid metadata: error building
schema: unable to build schema: metadata is not consistent: invalid
directions: Desc,Asc defined in orderByInput of GraphqlConfig ,
currenlty there is no support for partial directions. Please specify a
type which has both 'asc' and 'desc' directions"
7:56PM ERR Supergraph Build failed.

This has been fixed.

## Changelog

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [x] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [x] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

Fixed arbitrary ordering of directions in GraphqlConfig causing invalid
error

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: b27a0dd3b5c665f54ea58a40af8b2b1bfb0d2434
This commit is contained in:
Daniel Chambers 2024-05-28 15:42:58 +10:00 committed by hasura-bot
parent 01711c20da
commit a132759dac
2 changed files with 5 additions and 3 deletions

View File

@ -1,5 +1,7 @@
//! This is where we will resolve graphql configuration
use std::collections::HashSet;
use crate::helpers::types::mk_name;
use crate::types::error::{Error, GraphqlConfigError};
use lang_graphql::ast::common as ast;
@ -206,8 +208,8 @@ pub fn resolve_graphql_config(
// TODO: Naveen: Currently we do not allow enabling a specific direction
// for orderableField. In future when we support this, we would like to
// build different enum types for different variations of directions.
if order_by_enum_type.directions
!= vec![OrderByDirection::Asc, OrderByDirection::Desc]
if HashSet::from_iter(order_by_enum_type.directions.iter().cloned())
!= HashSet::from([OrderByDirection::Asc, OrderByDirection::Desc])
{
let invalid_directions = order_by_enum_type
.directions

View File

@ -34,7 +34,7 @@
},
"enumTypeNames": [
{
"directions": ["Asc", "Desc"],
"directions": ["Desc", "Asc"],
"typeName": "OrderByAscDesc"
}
]