Fix failed start up due to Contentful type changes#402
Merged
Conversation
cakr322
approved these changes
Aug 24, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
cer-graphql was not able to launch since at least a week ago. Error was "Query.featuredItemsItems defined in resolvers, but not in schemas"
The issue seems to be a possible change in the output of Contentful's GraphQL API, particularly for introspection query. We use the GraphQL schema and the list of types to determine which content types require a custom authentication resolver (see
getProtectedTypes()). The function would filter for types with "Filter" in it, then construct a list of resolver names based on types that have an ssoProtected field in it. The constructed names were made on the assumption that all "xFilter" types have a corresponding "x" type, but new(?) types seem to not match this pattern for linked items. The corresponding type name for them is "xItem". This results in the error because the generated resolver name does not match any queries.Solution
Rewrote the
getProtectedTypesfunction to iterate through all types. Filter for types that have an ssoProtected field and has contentfulMetadata field (though perhaps only checking for ssoProtected field is needed). Also add their corresponding collection queries. The embedded types are not included in the filtered list.Screenshots
Testing
Existing tests should pick up any problems.
Have the changes been checked in the following browsers?