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

Replace Path Variables In Vanilla Client (No HOC) #231

Closed
nrakochy opened this issue Sep 26, 2019 · 2 comments
Closed

Replace Path Variables In Vanilla Client (No HOC) #231

nrakochy opened this issue Sep 26, 2019 · 2 comments

Comments

@nrakochy
Copy link

Hi there,

I am having a bit of difficulty pulling the arguments from the query invocation onto the path variable inside of the directive.

I believe it is very similar this issue re: Replacing Path Variables, except in this case I am using the vanilla apollo client and no higher order component.

Upon invocation, I can see the logs with the correct id, but the breakpoint on the resolver inside of apollo-link-rest has args = {floor_space_id: undefined}.

I am not sure if this is a simple implementation error, or if this is a simpler example of the Replacing Path Variables issue noted above. Any help would be appreciated. Thanks.

Here is the client code (all of the extra params on queryOpts are attempts to pass in the variable)-

function getUsersOnFloor(floor_space_id: string) {
  console.error("INCOMING ID", floor_space_id);
  return client.query({
    query: GET_USERS_ON_FLOOR,
    variables: { floor_space_id },
    args: { floor_space_id },
    context: { floor_space_id },
    options: { floor_space_id }
  });
}

And here is the query -

import gql from "graphql-tag";

const GET_USERS_ON_FLOOR = gql`
  query UsersOnFloor($floor_space_id: String!) {
    User(floor_space_id: $floor_sys_id)
      @rest(
        type: "User"
        path: "x_nuvo_eam_floormapper/{args.floor_space_id}"
      ) {
      id
    }
  }
`;

There are no other apollo-links at the moment, and the client is set with defaults from import { ApolloClient } from "apollo-client";.

@fbartho
Copy link
Collaborator

fbartho commented Sep 26, 2019

image
I see in your screenshot a $floor_sys_id -- that looks like a typo to me. I think you want to change that line to:

    User(floor_space_id: $floor_space_id)

Thoughts @nrakochy ?

@nrakochy
Copy link
Author

Ah! 🤦‍♂ Unbelievable. Thanks for the prompt response. Definitely appreciated.

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