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

Support partial return values from denormalize() #9

Open
jonaskello opened this issue Aug 7, 2018 · 2 comments
Open

Support partial return values from denormalize() #9

jonaskello opened this issue Aug 7, 2018 · 2 comments

Comments

@jonaskello
Copy link
Member

Today the denormalize function only returns a result if the whole query could be resolved from cache. It would be nice it it could return as much as possible, and also return an updated version of the query with the available fields removed. That query could be used to fill the missing parts of the cache. This would work best with data that is read-only because otherwise you might get inconsistent data in cache unless you refetch the full query.

@jonaskello jonaskello changed the title Return diff of query Denormalize should return partial result and diff of query Aug 7, 2018
@jonaskello
Copy link
Member Author

Instead of returning partial as a boolean we could return the diffed query. This could be implemented today by always returning the full query and no result if something is missing.

@jonaskello
Copy link
Member Author

Perhaps returning partial should be optional for performance reasons. Bailing out early when data is missing will be quicker. Something like this could be used:

const denormResult = denormalize(query, variables, normMap, partial);

Where the partial parameter is a boolean specifying if partial results should be returned. The return value could include a similar partial flag to indicate if the result is partial.

export interface DenormalizationResult {
  readonly data: RootFields | undefined;
  readonly fields: FieldsMap;
  readonly partial: boolean;
}

However if the result should include the remaining query then perhaps that is enough:

export interface DenormalizationResult {
  readonly data: RootFields | undefined;
  readonly fields: FieldsMap;
  readonly remaining: GraphQL.Document | undefined;
}

@jonaskello jonaskello changed the title Denormalize should return partial result and diff of query Support partial return values from denormalize() Jul 21, 2019
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

1 participant