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

Make sure root query that returns object with ID is cached #40

Closed
stubailo opened this issue Mar 26, 2016 · 1 comment
Closed

Make sure root query that returns object with ID is cached #40

stubailo opened this issue Mar 26, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@stubailo
Copy link
Contributor

This test kinda describes the situation:

  it('properly normalizes a query with variables', () => {
    const query = `
      query myQuery($intArg: Int, $floatArg: Float, $stringArg: String) {
        id,
        stringField(arg: $stringArg),
        numberField(intArg: $intArg, floatArg: $floatArg),
        nullField
      }
    `;

    const variables = {
      intArg: 5,
      floatArg: 3.14,
      stringArg: 'This is a string!',
    };

    const result = {
      id: 'abcd',
      stringField: 'Heyo',
      numberField: 5,
      nullField: null,
    };

    const normalized = writeQueryToStore({
      result,
      query,
      variables,
    });

    assertEqualSansDataId(normalized, {
      [result.id]: {
        id: 'abcd',
        nullField: null,
        'numberField({"intArg":5,"floatArg":3.14})': 5,
        'stringField({"arg":"This is a string!"})': 'Heyo',
      },
    });
  });

(This is a note so that I can focus on a different thing)

@stubailo stubailo modified the milestone: alpha Mar 28, 2016
@stubailo stubailo self-assigned this Mar 28, 2016
@stubailo stubailo self-assigned this Apr 6, 2016
@stubailo
Copy link
Contributor Author

stubailo commented Apr 6, 2016

Oh, actually this is basically a malformed query.. for this result to actually work, id would have to be a root query on the schema, which would be ridiculous.

@stubailo stubailo closed this as completed Apr 6, 2016
jbaxleyiii pushed a commit that referenced this issue Oct 17, 2017
jbaxleyiii pushed a commit that referenced this issue Oct 18, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant