-
-
Notifications
You must be signed in to change notification settings - Fork 820
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
bugifx:mock interface type #332
Conversation
@bochen2014: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
is this project still maintained? @helfer |
@bochen2014 yes definitely - sorry, we've been traveling to some conferences recently and it's currently a Sunday. Let me take a look now. |
Hmm, I just looked around and it's my mistake that this made it into the docs. Looks like it started with this issue: #171 The original docs content submitted in the PR had a resolver that looked at |
I've temporarily reverted that docs change: https://github.com/apollographql/tools-docs/commit/d243bf0da9743c3a9e2320b735f18dd06c852a71 I think the right implementation here should have the following properties:
I think using |
Let me know if the above suggestions seem good to you. |
thanks @stubailo . yes your comments makes sense to me. all unit tests passed (including 2 new tests which I added as part of this PR). can you please review again? thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add explanation
@@ -61,6 +64,7 @@ describe('Mock', () => { | |||
returnListOfListOfIntArg(l: Int): [[Int]] | |||
returnListOfListOfObject: [[Bird!]]! | |||
returnStringArgument(s: String): String | |||
node(id:String!):Flying |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole idea of this PR is that, when you run node(id:'bee:123')
query, the mock server won't randomly choose a Flying
type (could be either Bee
or Bird
) but will run your mock of Flying
code (where you specify whether to return a bee
or bird
). It basically enables user to implement a id-fetcher
for their node interface (which is where this PR comes from)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but couldn't we support both things? Like if your mock returns a __typename
that is used (which supports your case) but if you don't want to care about that it will select a random one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. thats the current behavior.. still the same
Can we make sure that Unions behave the same way? https://github.com/apollographql/graphql-tools/pull/332/files#diff-483b6e7e62e3109d7c87ae3c54425430R199 I think that means factoring out the type selection logic into a function. |
will do it this morning... thanks |
hi @stubailo I've updated my PR to address unionTypes explicit mock. please review it again.. plus, your updated doc
seems to be a bit misleading.. I think for most users, leaving the parameter
|
@bochen2014 that's a good point. I'm going to review and merge this today, do you mind if I make some code changes along the way? |
feel free to change whatever you think is required ;-) |
any updates?😏 |
hi @stubailo have you got a chance to have a review? we actually need the change in our project . thanks |
Thanks @bochen2014 for the great PR and sorry for the delay! I will talk with @stubailo today and we'll get the PR merged asap! 🙂 |
Ok, I think this change is pretty good, but it's also a breaking change (because we're changing edit: since we never documented the automatic behavior with __typename, it should be ok to release it as a minor version. |
thanks @helfer for merging my pr! |
it didn't work for me by following
so I fixed the problem