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

mutation selectors should not include @live fields #159

Open
dustinfarris opened this issue Jan 12, 2017 · 3 comments
Open

mutation selectors should not include @live fields #159

dustinfarris opened this issue Jan 12, 2017 · 3 comments

Comments

@dustinfarris
Copy link
Contributor

dustinfarris commented Jan 12, 2017

If you have a mutation that returns an object (not a scalar), e.g.

schema {
  mutation: {
    updateProject: Project

cashay will build the mutation to select fields for that type to fulfill any active queries.

but cashay seems to ignore @live directives (and possibly @cached as well?)

e.g. if you have a query

project (id: $project_id) @live {
  id
  name
  projectTodos @live {
    id
    description
  }
}

when you run the mutation

cashay.mutate('updateProject', ...

cashay sends this to the server:

mutation ($id: ID!, $name: String!) {
  updateProject(id: $id, name: $name) {
    projectTodos @live {
      id
      description
    }
    id
    name
  }
}

which causes graphql to throw: Unknown directive "live".

@mattkrick
Copy link
Owner

when using mutations on live data, i have that mutation return a GraphQLBoolean or similar. The reason why is because if it's live, then you aren't going to respond directly, rather the response is going to come from your pubsub. otherwise, you'd be getting 2 results (1 for the requesting client, and another being the requesting entity is subscribed to that pubsub channel)

@dustinfarris
Copy link
Contributor Author

@mattkrick thanks, yeah i figured that much out. i do think there should be an error from cashay for such a mutation that selects live fields—but feel free to close if that's more of a roadmap thing

@mattkrick
Copy link
Owner

yeah, v2 i'm just gonna scrap the mutation-writing heuristic, which will solve this. it was cute, but annoying, specifically for this bug that lies in the graphql package (i still think calling a mutation w/o wanting anything back is useful & the fact that graphql disallows that is silly IMO).

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

No branches or pull requests

2 participants