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

Server: Remote relationships permissions #6125

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
eec029b
[WIP] add the `add_remote_schema_permissions` API
codingkarthik Sep 22, 2020
e3c772a
add validation for directives, enums and input objects
codingkarthik Sep 23, 2020
68f0dfa
add validation for interfaces, unions and object types
codingkarthik Sep 24, 2020
1d77539
integrate all validations into validateRemoteSchema
codingkarthik Sep 24, 2020
170e664
refactor CustomRemoteSchema to RoleBasedSchema
codingkarthik Sep 24, 2020
9600a9c
add function to format the errors
codingkarthik Sep 24, 2020
27e53ce
integrate role based remote schema validation into the API
codingkarthik Sep 25, 2020
f57f6c3
check for duplicate type names among the types
codingkarthik Sep 25, 2020
34a5ed9
fix object implementing interfaces validation
codingkarthik Sep 25, 2020
b16f6bf
add duplicate checks for args, fields and directives
codingkarthik Sep 25, 2020
a2e3624
add documentation to some of the functions in Validate module
codingkarthik Sep 25, 2020
4ceb271
build remote schema context with permissions
codingkarthik Sep 29, 2020
7ddc6e9
modify the schema cache to include remote schema with perms
codingkarthik Sep 29, 2020
aa51c23
generate role based schema for each role
codingkarthik Sep 29, 2020
56f7a43
[not compiling] delete remote schema perms metadata obj
codingkarthik Sep 29, 2020
4f16e46
enable lenses for 'RemoteSchemaCtxWithPermissions' type
rakeshkky Sep 29, 2020
3e1f857
add drop_remote_schema_permissions api and include dependencies
codingkarthik Sep 29, 2020
77d061e
Refactor SchemaDocumentTypeDefinitions to PartitionedTypeDefinitions
codingkarthik Sep 30, 2020
c328d3a
minor refactoring of the RemoteSchema/Validate.hs module
codingkarthik Sep 30, 2020
9d594e7
move ParitionedTypeDefinitions to Types/RemoteSchema.hs
codingkarthik Sep 30, 2020
4d1e47a
add remote schema permissions docs
codingkarthik Sep 30, 2020
b71a541
add feature flag to enable remote schema permissions
codingkarthik Sep 30, 2020
2f23019
don't expose remotes in unauthenticated context
codingkarthik Sep 30, 2020
56a2041
add remote schema permissions in import and export metadata
codingkarthik Sep 30, 2020
89d5929
fix the haskell tests
codingkarthik Sep 30, 2020
9a8a845
change permissions to be Maybe while exporting metadata
codingkarthik Oct 1, 2020
9e5dd5d
drop the related permissions while removing a remote schema
codingkarthik Oct 1, 2020
c9b11de
restrict adding remote schema permissions when permissions are not en…
codingkarthik Oct 1, 2020
73066a5
add a note about enabling remote schema permissions
codingkarthik Oct 1, 2020
a31fc86
add CHANGELOG
codingkarthik Oct 1, 2020
b96a932
report only non permission dependent objects while removing remote sc…
codingkarthik Oct 1, 2020
e4752dc
throw error when all non-nullable arguments to a field aren't provided
codingkarthik Oct 1, 2020
7d25284
compare only the names of the non nullable input args
codingkarthik Oct 1, 2020
4b3bd3a
add some validation tests for remote schema permissions
codingkarthik Oct 1, 2020
13e9f52
add more tests
codingkarthik Oct 1, 2020
9e100cb
add validation for object types
codingkarthik Oct 1, 2020
90f0f96
run remote schema permissions test in test-server.sh
codingkarthik Oct 1, 2020
3b70eb1
unset remote schema permsissions after testing
codingkarthik Oct 2, 2020
90b2aba
change the location of the remote schema permissions test
codingkarthik Oct 2, 2020
1f9e945
remove --hge-webhook flag from remote schema permissions tests
codingkarthik Oct 2, 2020
59c35b0
add failing remote schema permissions execution test
codingkarthik Oct 5, 2020
adecd5a
Merge branch 'master' into remote-schema-perms
codingkarthik Oct 13, 2020
fb1e93d
Merge branch 'master' into remote-schema-perms
codingkarthik Oct 13, 2020
e2cc299
add/modify some of the role-based remote schema tests
codingkarthik Oct 13, 2020
9c4df90
remove -fdefer-typed-holes from cabal.project
codingkarthik Oct 13, 2020
5a2e188
include directives for InputValueDefinition in appropriate places
codingkarthik Oct 13, 2020
e6621bb
add validation for preset directives
codingkarthik Oct 13, 2020
43f458a
use the correct tag of graphql-parser-hs
codingkarthik Oct 13, 2020
05ff97e
adjust the code after modifying G.InputValueDefinition
codingkarthik Oct 13, 2020
9c317df
add documentation to some of the function in RemoteSchema/Validate.hs
codingkarthik Oct 15, 2020
e78552b
change the type of RemoteField
codingkarthik Oct 15, 2020
d2fdf38
argument presets only for static values and arguments of field
codingkarthik Oct 15, 2020
6fd4aff
fix the arguments of `mkFieldParserWithSelectionSet`
codingkarthik Oct 15, 2020
17ecffd
compare the directives of input object field's arguments as well
codingkarthik Oct 15, 2020
d45511d
undo the static_preset and session_preset
codingkarthik Oct 16, 2020
61a9fe5
accomodate the changes after parametrizing G.TypeDefinition
codingkarthik Oct 16, 2020
e1d69fe
incorporate changes made after parametrizing G.InputObjectTypeDefinition
codingkarthik Oct 16, 2020
387adc6
[WIP] make modifications in remote schema stuff after changing G.Type…
codingkarthik Oct 16, 2020
1e85d81
[WIP] accomodate changes made in the remote schema introspection type
codingkarthik Oct 19, 2020
f5bce71
accomodate the changes after changing order of args in TypeDefinition
codingkarthik Oct 19, 2020
c0831c9
save the graphQL type with every variable value
codingkarthik Oct 19, 2020
6f7bfb6
[WIP] Change the return type of parsePresetDirective
codingkarthik Oct 19, 2020
23339cb
return a G.Value Variable instead of RemoteSchemaPresetArguments
codingkarthik Oct 20, 2020
a7bf820
implement presets for input object fields!!
codingkarthik Oct 21, 2020
3fb5d99
minor changes in the parsePresetDirective function
codingkarthik Oct 22, 2020
95736d2
add relationships between remote_schemas and remote_schema_permission
codingkarthik Oct 22, 2020
51fb4f7
Merge branch 'remote-schema-perms' into remote-schema-args-preset-inp…
codingkarthik Oct 22, 2020
23d3490
finish off remote schema session preset argument presets
codingkarthik Oct 22, 2020
378f5aa
validate the preset value
codingkarthik Oct 23, 2020
6efa3ce
minor refactorings in the remote schema validate file
codingkarthik Oct 23, 2020
b20ce33
throw error when trying to set session variable to list type
codingkarthik Oct 23, 2020
fff892c
rename validatePresetValue to parsePresetValue
codingkarthik Oct 23, 2020
468bdba
rename RemoteSchema/Validate.hs to RemoteSchema/Permission.hs
codingkarthik Oct 23, 2020
bbd6145
refactor RemoteSchemaCtxWithPermissions to RemoteSchemaCtx
codingkarthik Oct 23, 2020
0f88c19
Merge branch 'master' into remote-schema-args-preset-inp-obj-presets
codingkarthik Oct 26, 2020
ee15971
use the Printer instance of G.SchemaDocument in the ToJSON instance
codingkarthik Oct 26, 2020
5b8da91
use the appropriate env flag in parseEnabelRemoteSchemaPerms
codingkarthik Oct 27, 2020
ad8df34
apply hlint suggestions
codingkarthik Oct 27, 2020
f8a4ccb
handle static session variables values
codingkarthik Oct 27, 2020
965931d
remove graphql-engine +developer -profiling from cabal.project.freeze
codingkarthik Oct 27, 2020
1190014
Merge branch 'master' into remote-schema-args-preset-inp-obj-presets
codingkarthik Oct 27, 2020
b34e1b8
fix mutation bug, use G.OperationTypeMutation in mutation exec
codingkarthik Oct 27, 2020
c12e871
handle nullability for remote input objects
codingkarthik Oct 28, 2020
0e25ac5
fix failing role based remote schema tests
codingkarthik Oct 28, 2020
a66dde1
update tag of graphql-parser-hs with latest commit
codingkarthik Oct 28, 2020
35a3d7d
add RS permissions static argument preset tests
codingkarthik Oct 28, 2020
da77b8b
add some session arguments preset execution tests
codingkarthik Oct 28, 2020
8aa3801
document the mergeValue function in Remote.hs
codingkarthik Oct 28, 2020
a5d79fd
minor refactoring
codingkarthik Oct 28, 2020
16d2aed
document the argumentsParser function
codingkarthik Oct 28, 2020
aecf172
when schema definition is not provided, parse with default query root…
codingkarthik Oct 29, 2020
515186e
add some validation tests for preset arguments
codingkarthik Oct 29, 2020
f1b4491
change invalid-role-based-remote-schema to invalid-custom-remote-sche…
codingkarthik Oct 29, 2020
2539989
improve the mergeValue function to avoid partiality
codingkarthik Oct 29, 2020
aee1341
Merge branch 'master' into remote-schema-args-preset-inp-obj-presets
codingkarthik Oct 29, 2020
13ba1a4
use G.InputValueDefinition instead of RemoteSchemaInputValueDefinition
codingkarthik Oct 30, 2020
39de82b
add module documentation for `RemoteSchema/Permission.hs`
codingkarthik Oct 31, 2020
8cef016
add a separator to make the variable names distinct
codingkarthik Nov 2, 2020
13aab63
undo a unnecessary change and fix a TODO
codingkarthik Nov 2, 2020
4b8ab27
apply changes suggested in the docs
codingkarthik Nov 2, 2020
37b20f5
add docs about preset arguments in remote schema permissions docs
codingkarthik Nov 2, 2020
3f8a949
modify a failing test
codingkarthik Nov 2, 2020
26616b9
remove stray TODOs
codingkarthik Nov 2, 2020
4263ce0
[WIP] first step towards remote join permissions
codingkarthik Nov 2, 2020
4776c61
use the remote schema configured for the role instead of admin remotes
codingkarthik Nov 3, 2020
c41df70
derive remote schema permissions
codingkarthik Nov 3, 2020
1bba34f
add tests for remote join permissions
codingkarthik Nov 3, 2020
8c8cc49
Merge branch 'master' into remote-relationships-permissions
codingkarthik Nov 3, 2020
0cfb93f
move the remote relationship validation logic to remoteRelationshipField
codingkarthik Nov 3, 2020
4b7361a
[WIP] Deep parsing of remote join queries
codingkarthik Nov 4, 2020
3be4b7e
use the role's configured introspection instead of the upstream one
codingkarthik Nov 4, 2020
2366831
apply hlint suggestions
codingkarthik Nov 4, 2020
3011020
server: refactor the fetchRemoteJoinFields function
codingkarthik Nov 4, 2020
4f08afd
fix remote relationships when remote schema permissions were not enabled
codingkarthik Nov 4, 2020
4843ee2
Merge branch 'master' into remote-relationships-permissions
codingkarthik Nov 4, 2020
a25bafa
don't ignore presets for the non-joining arguments of the remote reln…
codingkarthik Nov 5, 2020
4be883e
get the variable infos from the selection set of the field as well
codingkarthik Nov 5, 2020
6bb0b1d
add tests for remote relationship permissions
codingkarthik Nov 5, 2020
7fde85b
add documentation for Remote Relationship Permissions
codingkarthik Nov 5, 2020
545acb4
Merge branch 'master' into remote-relationships-permissions
codingkarthik Nov 5, 2020
c13a051
apply hlint suggestions
codingkarthik Nov 5, 2020
7850c48
Merge branch 'master' into remote-relationships-permissions
codingkarthik Dec 22, 2020
900c9f7
Merge branch 'master' into remote-relationships-permissions
codingkarthik Dec 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
integrate all validations into validateRemoteSchema
  • Loading branch information
codingkarthik committed Sep 24, 2020
commit 1d77539d8ae07acbd12d3245a39041e13f284b93
2 changes: 1 addition & 1 deletion server/cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/codingkarthik/graphql-parser-hs.git
tag: 7fa233902ebe23a8644d29950cab98e261f74384
tag: 97b4b4ecc0d5a35c1c0bbf85cbb625442c360d94

source-repository-package
type: git
Expand Down
90 changes: 46 additions & 44 deletions server/src-lib/Hasura/RQL/DDL/RemoteSchema/Validate.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Hasura.RQL.DDL.RemoteSchema.Validate () where
module Hasura.RQL.DDL.RemoteSchema.Validate (
validateRemoteSchema
) where

import Control.Monad.Validate

import Hasura.Prelude
import Hasura.RQL.Types hiding (GraphQLType)
import Hasura.SQL.Types
import Hasura.Server.Utils (englishList)

Expand Down Expand Up @@ -46,33 +47,29 @@ data CustomRemoteSchemaValidationError
-- ^ error to indicate that an user provided
-- type differs from the type defined in the upstream
-- remote schema
| ExtraneousFields !GraphQLType !G.Name !(S.HashSet G.Name)
| ExtraneousFields !GraphQLType !G.Name !(NE.NonEmpty G.Name)
-- ^ error to indicate when an user provided type
-- has more fields than what's defined
-- in the remote schema
| ExtraneousArgs !GraphQLType !G.Name !(NE.NonEmpty G.Name)
-- ^ error to indicate when an user provided type
-- has more arguments than what's defined in a particular
-- type in the remote schema
| DifferingArgs !GraphQLType !(NE.NonEmpty G.Name)
| FieldDoesNotExist !GraphQLType !G.Name
-- ^ error to indicate when a single field doesn't exist
-- in the upstream remote schema
| NonMatchingDefaultValue !G.Name !G.Name !(Maybe (G.Value Void)) !(Maybe (G.Value Void))
-- ^ input-object-name - input-value-name - expected-def-val - provided-def-val
| NonExistingInputArgument !G.Name !G.Name
-- ^ input-object-name - argument-name
| NonExistingDirectiveArgument !G.Name ![G.Name]
| NonExistingDirectiveArgument !G.Name !GraphQLType !G.Name ![G.Name]
-- ^ directive-name - argument-name
| NonExistingField !G.Name !FieldDefinitionType !G.Name
-- ^ parent-type-name - "object/interface" - provided-name
| NonExistingScalar !G.Name
| NonExistingUnionMemberTypes !G.Name !(S.HashSet G.Name)
| NonExistingUnionMemberTypes !G.Name !(NE.NonEmpty G.Name)
-- ^ union name - extra-fields
| CustomInterfacesNotAllowed !G.Name !(NE.NonEmpty G.Name)
-- ^ object name - custom interfaces
| ObjectImplementsNonExistingInterfaces !G.Name !(NE.NonEmpty G.Name)
-- ^ object-name
| NonExistingEnumValues !G.Name !(NE.NonEmpty G.Name)
deriving (Show, Eq)

validateDirective
Expand All @@ -81,18 +78,18 @@ validateDirective
-> G.Directive a -- ^ original directive definition
-> (GraphQLType, G.Name) -- ^ parent type and name
-> m ()
validateDirective providedDirective originalDirective gType = do
validateDirective providedDirective originalDirective (parentType, parentTypeName) = do
if argsDiff == Map.empty
then pure ()
else
dispute $ pure $ NonExistingDirectiveArgument directiveName $ Map.keys argsDiff
dispute $ pure $
NonExistingDirectiveArgument parentTypeName parentType directiveName $ Map.keys argsDiff
where
argsDiff = Map.difference providedDirectiveArgs originalDirectiveArgs

providedDirectiveArgs = G._dArguments providedDirective
originalDirectiveArgs = G._dArguments originalDirective

extraneousKeys = Map.keys $ Map.difference providedDirectiveArgs originalDirectiveArgs
directiveName = G._dName providedDirective

validateDirectives
Expand Down Expand Up @@ -128,31 +125,27 @@ formatErrorMsg errorItems =
-- provided by the user against the enum definition defined
-- in the remote
validateEnumTypeDefinition
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
:: ( MonadValidate [CustomRemoteSchemaValidationError] m)
=> G.EnumTypeDefinition -- ^ provided enum type definition
-> G.EnumTypeDefinition -- ^ original enum type definition
-> m ()
validateEnumTypeDefinition providedDefn originalDefn = do
validateDirectives (G._etdDirectives providedDefn) (G._etdDirectives originalDefn) $ (Enum, enumFieldName)
case fieldsDifference of
empty -> pure ()
extraFields -> dispute $ pure $ ExtraneousFields Enum enumFieldName extraFields
pure ()
validateEnumTypeDefinition providedEnum upstreamEnum = do
validateDirectives providedDirectives upstreamDirectives $ (Enum, providedName)
onJust (NE.nonEmpty $ S.toList fieldsDifference) $ \nonExistingEnumVals ->
dispute $ pure $ NonExistingEnumValues providedName nonExistingEnumVals
where
providedEnumDirectives = (G._etdDirectives providedDefn)
G.EnumTypeDefinition _ providedName providedDirectives providedValueDefns = providedEnum

originalEnumDirectives = G._etdDirectives originalDefn
G.EnumTypeDefinition _ upstreamName upstreamDirectives upstreamValueDefns = upstreamEnum

providedEnumValNames = map (G.unEnumValue . G._evdName) (G._etdValueDefinitions providedDefn)
providedEnumValNames = map (G.unEnumValue . G._evdName) $ providedValueDefns

originalEnumValNames = map (G.unEnumValue . G._evdName) (G._etdValueDefinitions originalDefn)
upstreamEnumValNames = map (G.unEnumValue . G._evdName) $ upstreamValueDefns

fieldsDifference = getDifference providedEnumValNames originalEnumValNames

enumFieldName = G._etdName providedDefn
fieldsDifference = getDifference providedEnumValNames upstreamEnumValNames

validateEnumTypeDefinitions
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
:: ( MonadValidate [CustomRemoteSchemaValidationError] m)
=> [G.EnumTypeDefinition]
-> [G.EnumTypeDefinition]
-> m ()
Expand Down Expand Up @@ -181,7 +174,7 @@ validateInputValueDefinition providedDefn upstreamDefn inputObjectName = do
pure ()
where
G.InputValueDefinition _ providedName providedType providedDefaultValue = providedDefn
G.InputValueDefinition _ upstreamName upstreamType upstreamDefaultValue = upstreamDefn
G.InputValueDefinition _ _ upstreamType upstreamDefaultValue = upstreamDefn

validateArguments
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
Expand Down Expand Up @@ -210,7 +203,7 @@ validateInputObjectTypeDefinition providedInputObj upstreamInputObj = do
where
G.InputObjectTypeDefinition _ providedName providedDirectives providedArgs = providedInputObj

G.InputObjectTypeDefinition _ upstreamName upstreamDirectives upstreamArgs = upstreamInputObj
G.InputObjectTypeDefinition _ _ upstreamDirectives upstreamArgs = upstreamInputObj

validateInputObjectTypeDefinitions
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
Expand Down Expand Up @@ -260,20 +253,20 @@ validateFieldDefinitions providedFldDefnitions upstreamFldDefinitions (parentTyp
validateInterfaceDefinition
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
=> G.InterfaceTypeDefinition ()
-> G.InterfaceTypeDefinition [G.Name]
-> G.InterfaceTypeDefinition ()
-> m ()
validateInterfaceDefinition providedInterfaceDefn upstreamInterfaceDefn = do
validateDirectives providedDirectives upstreamDirectives $ (Interface, providedName)
validateFieldDefinitions providedFieldDefns upstreamFieldDefns $ (InterfaceField, providedName)
where
G.InterfaceTypeDefinition _ providedName providedDirectives providedFieldDefns _ = providedInterfaceDefn

G.InterfaceTypeDefinition _ upstreamName upstreamDirectives upstreamFieldDefns _ = upstreamInterfaceDefn
G.InterfaceTypeDefinition _ _ upstreamDirectives upstreamFieldDefns _ = upstreamInterfaceDefn

validateInterfaceDefinitions
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
=> [G.InterfaceTypeDefinition ()]
-> [G.InterfaceTypeDefinition [G.Name]]
-> [G.InterfaceTypeDefinition ()]
-> m ()
validateInterfaceDefinitions providedInterfaces upstreamInterfaces = do
flip traverse_ providedInterfaces $ \providedInterface@(G.InterfaceTypeDefinition _ name _ _ _) -> do
Expand All @@ -294,7 +287,7 @@ validateScalarDefinition providedScalar upstreamScalar = do
where
G.ScalarTypeDefinition _ providedName providedDirectives = providedScalar

G.ScalarTypeDefinition _ upstreamName upstreamDirectives = upstreamScalar
G.ScalarTypeDefinition _ _ upstreamDirectives = upstreamScalar

validateScalarDefinitions
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
Expand All @@ -317,8 +310,8 @@ validateUnionDefinition
-> m ()
validateUnionDefinition providedUnion upstreamUnion = do
validateDirectives providedDirectives upstreamDirectives $ (Union, providedName)
when (S.empty /= memberTypesDiff) $ do
refute $ pure $ NonExistingUnionMemberTypes providedName memberTypesDiff
onJust (NE.nonEmpty $ S.toList memberTypesDiff) $ \nonExistingMembers ->
refute $ pure $ NonExistingUnionMemberTypes providedName nonExistingMembers
where
G.UnionTypeDefinition _ providedName providedDirectives providedMemberTypes = providedUnion

Expand Down Expand Up @@ -368,13 +361,13 @@ validateObjectDefinition providedObj upstreamObj interfacesDeclared = do

nonExistingInterfaces = S.toList $ S.difference providedIfacesSet interfacesDiff

validateObjectTypeDefinitions
validateObjectDefinitions
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
=> [G.ObjectTypeDefinition]
-> [G.ObjectTypeDefinition]
-> S.HashSet G.Name
-> m ()
validateObjectTypeDefinitions providedObjects upstreamObjects providedInterfaces = do
validateObjectDefinitions providedObjects upstreamObjects providedInterfaces = do
flip traverse_ providedObjects $ \providedObject@(G.ObjectTypeDefinition _ name _ _ _) -> do
upstreamObject <-
onNothing (Map.lookup name upstreamObjectsMap) $
Expand All @@ -385,22 +378,31 @@ validateObjectTypeDefinitions providedObjects upstreamObjects providedInterfaces

-- For the love of god, This function needs to be refactored :(
validateRemoteSchema
:: (MonadValidate [CustomRemoteSchemaValidationError] m)
:: ( MonadValidate [CustomRemoteSchemaValidationError] m)
=> G.SchemaDocument
-> G.SchemaIntrospection
-> m G.SchemaIntrospection
validateRemoteSchema (G.SchemaDocument typeSystemDefinitions) x@(G.SchemaIntrospection originalTypeDefns) = do
validateRemoteSchema (G.SchemaDocument typeSystemDefinitions) x@(G.SchemaIntrospection upstreamSchemaTypes) = do
let
(_, typeDefns) = flip runState emptySchemaDocTypeDefinitions $
(_, providedTypes) = flip runState emptySchemaDocTypeDefinitions $
traverse resolveTypeSystemDefinitions typeSystemDefinitions
objDefs = _sdtdObjects typeDefns
(_, upstreamTypes) = flip runState emptySchemaDocTypeDefinitions $
traverse resolveSchemaIntrospection upstreamSchemaTypes
objDefs = _sdtdObjects providedTypes
possibleTypesMap = createPossibleTypesMap objDefs
interfaceDefsWithPossibleTypes = map (\iface -> -- UGH!
let name = G._itdName iface
in
iface
{G._itdPossibleTypes =
fromMaybe [] (Map.lookup name possibleTypesMap)})
providedInterfacesList = map G._itdName $ _sdtdInterfaces providedTypes
validateScalarDefinitions (_sdtdScalars providedTypes) (_sdtdScalars upstreamTypes)
validateObjectDefinitions (_sdtdObjects providedTypes) (_sdtdObjects upstreamTypes) $ S.fromList providedInterfacesList
validateInterfaceDefinitions (_sdtdInterfaces providedTypes) (_sdtdInterfaces upstreamTypes)
validateUnionTypeDefinitions (_sdtdUnions providedTypes) (_sdtdUnions upstreamTypes)
validateEnumTypeDefinitions (_sdtdEnums providedTypes) (_sdtdEnums upstreamTypes)
validateInputObjectTypeDefinitions (_sdtdInputObjects providedTypes) (_sdtdInputObjects upstreamTypes)
return x
where
-- Construction of the `possibleTypes` map for interfaces, while parsing the
Expand Down Expand Up @@ -438,7 +440,7 @@ validateRemoteSchema (G.SchemaDocument typeSystemDefinitions) x@(G.SchemaIntrosp
resolveTypeSystemDefinitions (G.TypeSystemDefinitionType typeDefn) =
resolveTypeDefinition typeDefn

-- resolveSchemaIntroSpection :: G.TypeDefinition [G.Name] -> State SchemaDocumentTypeDefinitions ()
-- resolveSchemaIntroSpection typeDef = resolveTypeDefinition $ typeDef $> ()
resolveSchemaIntrospection :: G.TypeDefinition [G.Name] -> State SchemaDocumentTypeDefinitions ()
resolveSchemaIntrospection typeDef = resolveTypeDefinition (typeDef $> ())

emptySchemaDocTypeDefinitions = SchemaDocumentTypeDefinitions [] [] [] [] [] [] []