Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

sorting with aliases #75

Open
jexp opened this issue May 27, 2020 · 0 comments
Open

sorting with aliases #75

jexp opened this issue May 27, 2020 · 0 comments

Comments

@jexp
Copy link
Collaborator

jexp commented May 27, 2020

I used an alias in my graphql query but all the react queries failed
because the sorting has to contain the original name not the alias.
Not sure if that's an issue with react passing the order by as a parameter, I think rather that neo4j-graphql-js should take the alias into account.

const GET_USER = gql`
  query usersPaginateQuery(
    $first: Int
    $offset: Int
    $orderBy: [_UserOrdering]
    $filter: _UserFilter
  ) {
    User(first: $first, offset: $offset, orderBy: $orderBy, filter: $filter) {
      id
      name: display_name
      reputation
    }
  }
`

changes I had to make (from "name" to display_name

function UserList(props) {
  const { classes } = props
  const [order, setOrder] = React.useState('asc')
  const [orderBy, setOrderBy] = React.useState('display_name') // <- here
              <TableCell
                key="name"
                sortDirection={orderBy === 'name' ? order : false}
              >
                <Tooltip title="Sort" placement="bottom-start" enterDelay={300}>
                  <TableSortLabel
                    active={orderBy === 'name'}
                    direction={order}
                    onClick={() => handleSortRequest('display_name')} <!-- here -->
                  >
                    Name
                  </TableSortLabel>
                </Tooltip>
              </TableCell>

this makes it kinda inconsistent and hard to reason about.

##Also Error Handling

When the errors occurred I only saw Error in the UI, no error message, not even in chrome debug tools

I had to run the query with the params from the react app manually against the graphql api to see the error message

it was also no error output in the terminal of api or web-react, even as it was running in dev-mode.

Bildschirmfoto 2020-05-27 um 12 20 23

And no "errors" response data, but an HTTP 400

Bildschirmfoto 2020-05-27 um 12 34 22

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant