graphql-faker
graphql-faker copied to clipboard
Specify number of items in array
Would it be possible to add the ability to specify the number of items in a list? I would imagine being able to enter a min number and max number then it returns a random number of items within that range. If the numbers are the same then obviously it just returns that number. An example of syntax is below but you might have a better idea.
@chookie Thank you for the idea it's definitely something we need to add to Faker.
It partly overlaps with validation tool we plan to work on so you could specify @list(minItems: 5, maxIterms: 10)
for input value and we want to reuse the same directives inside Faker.
We still didn't finish with the design of these directives so it will take some time before we can add this feature to Faker.
Hello, @IvanGoncharov This list length will be very useful for us ;) When we can have this feature?
@zachzhi I plan to spend some time on Faker in the second half of this month and this issue is on my checklist. Hower before implementing it I want to switch to official graphql-js
instead of the custom fork and write some basic tests.
I will ping you when I will have some prototype to test.
Any update on this? Thank you for the tool, looks very promising 👍
@OlzhasAlexandrov I'm still working on pushing necessary functionality in the graphql-js. It's extremely slow and time-consuming 😞 but I managed to push like 80% required for APIs-guru/graphql-*
projects.
For this particular project, I still need to push one PR that will allow switching away from the custom fork of express-graphql
.
TL;DR; I'm working on my checklist but its very very slow progress.
@OlzhasAlexandrov happy to help. I might learn something. Need/want help?
I would be glad to help also, there is any todo list/PR/branch/fork that I can look into?
Constantly just being given 3-4 elements in array, I have a use case here that required like 1000-10000 items on UI. Is there anyway to achieve that so far?
p.s @IvanGoncharov May be you can pint out to the related line of code where I just can hard-code the number of items so I can build custom version of faker just to be able to play with long lists.
@kuncevic Still planning to implement this, it's in my queue.
May be you can pint out to the related line of code where I just can hard-code the number of items so I can build custom version of faker just to be able to play with long lists.
https://github.com/APIs-guru/graphql-faker/blob/2f58a7f4fc230609756b97f16bd3615df1c162d4/src/fake_schema.ts#L182
Just modified node_modules\graphql-faker\dist\fake_schema.js
at var length = fake_1.getRandomInt(500, 1000);
for now which is a bit dirty but works for my use case.
Hello everyone, I just created #61 as I desperately need this feature and hardcoding is no-go in my case. Check it out :)
My proposal is following
employees: [Employee] @sample(min: 10, max: 20)
/cc: @IvanGoncharov
Why call it @sample
? why not sth like @itemCount
or @items
? Otherwise looks neat :)
Why call it
@sample
? why not sth like@itemCount
or@items
? Otherwise looks neat :)
I had same thought, but I would stick to @fakeArray in such case this way it is really self explained, e.g:
employees: [Employee] @fakeArray(min: 10, max: 20)
It's been a while since last posts 😄 ... but wondering if you are aware of something that fills the need?
Thank you,
EDIT: oh sorry, it seems it has been solved 1 year later by https://github.com/APIs-guru/graphql-faker/commit/5db15f66f13c0c69f7d69b3be004ffd0ba455f05 (maybe close this issue?)