-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fallbackid #8
Fallbackid #8
Conversation
One point of discussion is the signature on the user supplied |
Yes that was my first idea. But I went with a non breaking solution for the first implementation. I try to think of any possible use case for the implementor of |
src/types.ts
Outdated
) => string; | ||
}, | ||
path: ReadonlyArray<string> | ||
) => string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonaskello maybe it would be clearer if getObjectToId
returned a "resultobject" which could look like
export type ObjectToIdResult = ObjectToIdResultSuccess | ObjectToIdResultFailure
export interface ObjectToIdResultSuccess {
readonly resolved: true;
readonly id: string
}
export interface ObjectToIdResultFailure {
readonly resolved: false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have som performance tests what implications code changes has
I have tried different approaches regarding to performance but it is hard to get an reliable result. Sometimes the normalize is slower than denormalize, sometimes the other way around. But using less objects and more primitives should be faster so i changed export type GetObjectToIdResult = string | undefined;
export type GetObjectId = (
object: {
readonly id?: string;
readonly __typename?: string;
}
) => GetObjectToIdResult; |
Regarding performance one idea could be to use benchmarkjs. Since benchmarking results may be different between rounds, I think this is mostly useful for comparing things. So one could make a script to compare the latest published version on npm to the current master version for example. |
@jonaskello this is almost exactly what i did. I added benchmarkjs projects and have created a simple performance test. I just didn't get the package from npm, only tested with master branch and my feature branch. But the result was different from time to time. Sometimes the master branch was faster and sometimes the feature branch. PS: I only did a test with node. No browsers |
Ok, well that's interesting anyway. Did you add those scripts to package.json? |
Yes just run |
Here is a WIP for fallback id