-
-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use improved mapSchema to make schema package functions not modify ex…
…isting schema (#1456) * refactor WrapFields = add enhanceSchema function that can add/replace types/directives, see detailed comment with regard to motivation even for simply adding a new type (vs just using toConfig) = simplify field helper functions more complex modifyFields function is not necessary, empty types can be added and later extended so if multiples types with cross-referencing fields need to be added, the types can be added first without fields, and the fields appended later. = appendFields currently adds fields to a new type if no existing type is found, this functionality perhaps should be made configurable or put in a separate function * convert default values as leaf values internal values may change when mapping this is necessary to eventually replace use of healSchema and forEachDefaultValue within AddResolversToSchema, although use of mapSchema will require that function to be immutable * use TypeMap type * rename functions = appendObjectFields and removeObjectFields better describe that these functions only apply to fields of GraphQLObjectType = enhanceSchema is a bit vague * fix mapSchema typo All input types mapped to input object types! * continue mutable => immutable conversion This change: = bring default value updating into mapSchema = change aaddResolversToSchema, addCatchUndefinedToSchema, addErrorLoggingToSchema, addSchemaLevelResolver to all use mapSchema to return a new schema without modifying the passed in schema = change all internal use of these functions and all tests to use the return value = pass typeName instead of a type to field mappers, as passing a type can be confusing, because the type may be in the process of being mapped and not equivalent to the type in the original schema ** the visitSchema function and the schema directive classes that use visitSchema are the next (final?) target for mutable => immutable conversion * fix more docs * prune unnecessary field mapper types there are only really two types of fields, "composite fields" or "output fields" called "fields" in graphql-js on object and interfaces, and input fields on input objects. The generic FieldMapper type is useful for internal function mapFields so that field mapping logic does not have to be duplicated between output and input fields because of the different types.
- Loading branch information
Showing
37 changed files
with
774 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.