ardatan / ardatan/graphql-tools
[mock][store] Storing an object that its id is different with the key
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
I want to store a customer by its token. This is a sample code:
```ts
store.set('Customer', token, customer);
```
But I get this error:
Field id is a key field of Customer and you are trying to set it to `` while the key is ``
It would be great if I can store objects with any arbitrary key.
**Why do we need this feature?**
Using a token as a key, we can have multiple versions of any mocked customer. Then the mock server will be able to handle multiple e2e tests that are running for the same `customerId` in different sessions.
Contributor guide
Research direction
No file or test is named. Start by locating the mock store implementation and the validation that rejects a key differing from the object's id, using the `store.set('Customer', token, customer)` example and reported error as entry points. Done means arbitrary keys can store multiple mocked customer versions for separate sessions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100