question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to pass a sortBy param and sort by an endpoint?

This may be too much of a stretch, but sometimes for testing purposes we want to get data sorted by name, time, or another value.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanGoncharovcommented, Oct 24, 2019

@LeeroyJenks Thanks for providing more details. I think it’s too specific to be handled by graphql-faker itself but I think it’s an excellent use case to add middleware support into faker. For example:

export default const resolverWrappers = {
  Query: {
    async cosumer(source, args, ctx, info, next) {
      const consumers = await next(source, args, ctx, info);

      return consumers.slice().sort((consumer1, consumer2) => {
        return consumer1.name.localeCompare(consumer2.name);
      });
    }
  }
}

and run as graphql-faker --resolversJS ./customresolvers.js ... Note: It’s just an example I brain storm in like 10m

@LeeroyJenks What do you think about this idea in general?

0reactions
knidarknesscommented, Oct 25, 2019

@IvanGoncharov, if you think that would be good feature to have (middlewares) I could take a look and work on its implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux shell sort file according to the second column?
To sort by second field only (thus where second fields match, those lines with matches remain in the order they ...
Read more >
Sort by field - The Modern JavaScript Tutorial
We've got an array of objects to sort: let users = [ { ...
Read more >
Specifying the sorting field - IBM
If more than one field is to be sorted on, the records are sorted first according to the first field, and then those...
Read more >
SORT command in Linux/Unix with examples - GeeksforGeeks
SORT command is used to sort a file, arranging the records in a particular order. ... Use the -k option to sort on...
Read more >
How to Sort in Linux Bash by Column - Linux Hint
We use sort command to get an ordered output of a file in ascending, descending, or custom-defined ... To sort by the first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found