Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships (ie ID) #39

Open
desdemcmxcii opened this issue Feb 2, 2018 · 3 comments
Open

Relationships (ie ID) #39

desdemcmxcii opened this issue Feb 2, 2018 · 3 comments

Comments

@desdemcmxcii
Copy link

Is there anyway to mock relationships? We have a use case where two seperate queries have an ID field, which in our production implementation actually would be the same, and we do some transformative work to lookup by matching IDs.

ie.

{ field: 'thing1', id: 22 }
{ link: '22', id: 22 }

Currently faker randomizes IDs, but there seems to be no way to specify if a relationship should exist so that we can develop against "sane" faked data.

Hopefully that's clear enough, wondering if there is a solution for this kind of scenario.

@IvanGoncharov
Copy link
Member

@jamesc892 It's very hard to generate "sane" data in a tool that doesn't know your application logic.
I can suggest two approaches:

  • you can restrict possible IDs by adding @examples(values: [22, 23]) to ID field
  • you can write a minimal GraphQL server with object having only id fields and use Faker in extend mode to add the rest: https://github.com/APIs-guru/graphql-faker#tldr

@desdemcmxcii
Copy link
Author

desdemcmxcii commented Feb 5, 2018

Yeah I agree that sane data in its entirety would be out of scope. But for one off relationships, maybe not so much?

For context, we are trying to have on the fly introspection of our schema, and dynamically render faked data to avoid the need for engineers to do much from a configuration sense. Thinking thru the manual approach of restricting IDs and writing a minimal server to help were both scenarios we thought of, however they became a little too manual. We were hoping there was a flag that we could generate on our introspected schema to not rely on much static definition as we have a pretty robust API. We hoped something like a decorator @relationship(alias) that takes an alias that would link two ids together could be feasible. I think we've reached limitations of this and other tools we've tried.

We'll reconvene here, and possibly throw you a PR if we think thru an aliased relationship approach, if that sounds interesting to you.

@IvanGoncharov
Copy link
Member

@jamesc892 If you can suggest some general mechanism that would be useful to other users then I have no problem merging your PR or implementing it myself.

At the moment it hard for me to understand your proposal so can you please describe your setup step by step:

  1. You are using --extend mode or fake entire schema?
  2. Can you please write simplified IDL/SDL?
  3. Please provide two queries (you mentioned in the initial comment) against faked API with conflicting IDs.

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

No branches or pull requests

2 participants