Skip to content

Commit

Permalink
add comments for v7
Browse files Browse the repository at this point in the history
consider removing minimal level of pruning built into healSchema and mapSchema in the next major version, as built in pruning makes it impossible to build unpruned schemas, which may be of use to some library users
  • Loading branch information
yaacovCR committed Jun 11, 2020
1 parent f1fcab8 commit 8f8e96a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/utils/src/heal.ts
Expand Up @@ -121,6 +121,9 @@ export function healTypes(
}

if (!config.skipPruning) {
// TODO:
// consider removing the default level of pruning in v7,
// see comments below on the pruneTypes function.
pruneTypes(originalTypeMap, directives);
}

Expand Down Expand Up @@ -220,6 +223,14 @@ export function healTypes(
}
}

// TODO:
// consider removing the default level of pruning in v7
//
// Pruning was introduced into healSchema in v5, so legacy schema directives relying on pruning
// during healing are likely to be rare. pruning is now recommended via the dedicated pruneSchema
// function which does not force pruning on library users and gives granular control in terms of
// pruning types. pruneSchema does recreate the schema -- a parallel version that prunes in place
// could be considered.
function pruneTypes(typeMap: Record<string, GraphQLNamedType | null>, directives: ReadonlyArray<GraphQLDirective>) {
const implementedInterfaces = {};
Object.values(typeMap).forEach(namedType => {
Expand Down
10 changes: 10 additions & 0 deletions packages/utils/src/rewire.ts
Expand Up @@ -67,6 +67,9 @@ export function rewireTypes(

const newDirectives = directives.map(directive => rewireDirective(directive));

// TODO:
// consider removing the default level of pruning in v7,
// see comments below on the pruneTypes function.
return options.skipPruning
? {
typeMap: newTypeMap,
Expand Down Expand Up @@ -199,6 +202,13 @@ export function rewireTypes(
}
}

// TODO:
// consider removing the default level of pruning in v7
//
// Pruning during mapSchema limits the ability to create an unpruned schema, which may be of use
// to some library users. pruning is now recommended via the dedicated pruneSchema function
// which does not force pruning on library users and gives granular control in terms of pruning
// types.
function pruneTypes(
typeMap: TypeMap,
directives: Array<GraphQLDirective>
Expand Down

0 comments on commit 8f8e96a

Please sign in to comment.