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

feat(query): add support for query by reference #112

Closed
wants to merge 1 commit into from

Conversation

choyongjoon
Copy link

@tothandras
Copy link
Contributor

Looks good! Can you add at least one test case?

@choyongjoon
Copy link
Author

I've tried to make a test. But I got test errors.
Can you check it and show me the way?

choyongjoon@0b76253

@tothandras
Copy link
Contributor

We should probably create end-to-end (e2e.spec.js) tests first.
I was playing with the model in #103.
1.

mutation AddForum {
  addForum(input: {title: "foo", clientMutationId: "1"}) {
    changedForumEdge {
      node {
        id
      }
    }
  }
}
mutation AddTopic {
  addTopic(input: {title: "bar", clientMutationId: "2", uuid: "uuid", forum: "id from previous response"}) {
    changedTopicEdge {
      node {
        id
      }
    }
  }
}
query TopicsByForum{
  topics(forum: "this with mongoose ObjectId, but it doesn't with GraphQL ID") {
    forum {
      id
      _id
      title
    }
  }
}

# error
"Cast to ObjectId failed for value \"Rm9ydW06NTcyNzlkM2RjNWQ2MDg3NTBkN2E5YzM4\" at path \"forum\""

The reason that it can't accept GraphQL ID is that here we only convert the id or _id fields from GraphQL to mongoose ID. We need to process all fields with something like:
selector = mapValues(selector, (field) => processId({id: field}));.

@developer-rakeshpaul
Copy link

@tothandras any luck on this PR?

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

Successfully merging this pull request may close these issues.

3 participants