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

(graphcache) - Allow partial schema to be passed for altered root names #1379

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

kitten
Copy link
Member

@kitten kitten commented Feb 10, 2021

Resolve #1378

Summary

I had some of these changes done in a forgotten branch but never proposed / opened this since we didn't have a corresponding RFC just yet, and I didn't have time to write it up.

Basically, we should allow the root names to be altered without enabling full schema awareness for exceptional cases where schema awareness is explicitly not wanted. This is rather rare with the advent of GraphQL Code Generator's built-in plugin to resolve this at build time / deploy time but it may be helpful still.

It's now possible to pass only the root names like so:

const introspection = {
  __schema: {
    queryType: {
      name: 'query_root',
    },
    mutationType: {
      name: 'mutation_root',
    },
    subscriptionType: {
      name: 'subscription_root',
    },
  },
};

cacheExchange({ schema: introspection });

Set of changes

  • Make SchemaIntrospector.types optional and don't add it for partial schema introspection results
  • Prevent this.schema from being set on Store when SchemaIntrospector.types is missing
  • Update types in schemaPredicates.ts and fix up a test for this use-case
  • Allow a partial introspection result to be passed to schema

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2021

🦋 Changeset detected

Latest commit: ecf8610

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/exchange-graphcache Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten force-pushed the feat/allow-altered-rootnames branch from dc6346f to ecf8610 Compare February 10, 2021 16:05
@kitten kitten merged commit d0e067a into main Feb 10, 2021
@kitten kitten deleted the feat/allow-altered-rootnames branch February 10, 2021 16:11
@github-actions github-actions bot mentioned this pull request Feb 10, 2021
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

Successfully merging this pull request may close these issues.

RFC: Allow root types override without Schema Awareness
2 participants