You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
When using the graphQL filler to generate data with nested arrays, a faker seed collision occurs when generating the data for the elements in the arrays.
This is because the seedFromKeypath generates a seed from the keypath of the node that is being filled, based on the collective sum of all of the characters that make up that keypath.
If we have two people with two pets each, the pets at person[0].pet[1] and person[1].pet[0] have the same seed generated, because their "sum" of the chars in the keypath is the same. Because of this, their IDs are the same.
This becomes a problematic issue when combined with the Apollo cache. By default, Apollo will normalise the items based on their id fields and so we get a cache collision and the test data we receive in a call to the Apollo client does not match the data we passed to the createGraphQLFactory result.
This crops up with a single entity too, you don't even need nesting for this to fail. These key paths will result in the same seed: person[12] and person[21] (and thus the 12th and 21st person will be the same)
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Overview
When using the graphQL filler to generate data with nested arrays, a
faker
seed collision occurs when generating the data for the elements in the arrays.This is because the
seedFromKeypath
generates a seed from the keypath of the node that is being filled, based on the collective sum of all of the characters that make up that keypath.Example:
Given this schema:
If we have two people with two pets each, the pets at
person[0].pet[1]
andperson[1].pet[0]
have the same seed generated, because their "sum" of the chars in the keypath is the same. Because of this, their IDs are the same.Failing test here:
https://github.com/Shopify/quilt/compare/graphql-fixtures/seed-collision
This becomes a problematic issue when combined with the Apollo cache. By default, Apollo will normalise the items based on their
id
fields and so we get a cache collision and the test data we receive in a call to the Apollo client does not match the data we passed to thecreateGraphQLFactory
result.Potentially we could use some other stable method for generating the seed based on the keypath. Maybe some quick hash of the string? https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0
The text was updated successfully, but these errors were encountered: