@@ -40,8 +40,6 @@ Mutation.createUser.query.me
40
40
41
41
42
42
PlanOptions(path):
43
-
44
-
45
43
- Let {pathElements} be the list of tuples ({type}, {field}) in the provided {path}.
46
44
47
45
- Let ({initialType}, {initialField}) be the first element in {pathElements}.
@@ -52,6 +50,7 @@ PlanOptions(path):
52
50
- Continue to the next {sourceSchema}.
53
51
- Add {sourceSchema} to {sourceSchemas}.
54
52
53
+ PlanOptionsInternal(path, sourceSchemas):
55
54
- For each {pathElement} in {pathElements} starting from the second element:
56
55
- Initialize a new empty set {nextSchemas}.
57
56
- Set {currentType} and {currentField} to the respective elements of the current {pathElement}.
@@ -61,17 +60,16 @@ PlanOptions(path):
61
60
- Continue to the next {candidateSchema}.
62
61
63
62
- If {candidateSchema} not equals {currentSchema}:
64
- - Continue to the next {candidateSchema}.
65
- - If {IsReachable(option, candidateSchema, currentType)} returns false:
66
- - Continue to the next {candidateSchema}.
63
+ - If {IsReachable(currentSchema, candidateSchema, currentType)} returns false:
64
+ - Continue to the next {candidateSchema}.
67
65
68
66
- If {currentField} on {currentType} in {candidateSchema} defines a requirement:
69
- - If {ResolveRequirement(candidateSchema, currentType, currentField)} returns a valid requirement:
70
- - If the requirement is not satisfied by {currentSchema}:
67
+ - If {ResolveRequirement(currentSchema, candidateSchema, currentType, currentField)} returns false:
71
68
- Continue to the next {candidateSchema}.
69
+
72
70
- Add {candidateSchema} to {nextSchemas}.
73
71
74
- - If {nextSchemas} is empty after :
72
+ - If {nextSchemas} is empty:
75
73
- Return an empty set.
76
74
77
75
- Set {sourceSchemas} equal to {nextSchemas} to proceed to the next element in the path.
@@ -82,29 +80,39 @@ IsReachable(sourceSchema, targetSchema, type):
82
80
- If {targetSchema} does not define {type}
83
81
- return false
84
82
- If {sourceSchema} equals {targetSchema}
85
- - return true
83
+ - Assert: TODO This should be a precondition
86
84
- Let {lookups} be the set of all lookup fields in {targetSchema} that return {type}
87
85
- For each {lookup} in {lookups}:
88
86
- Let {keyFields} be the set of fields that form the key for {lookup} in {targetSchema}
89
- - If {keyFields} is empty
90
- - return false // ??
91
87
- For each {keyField} in {keyFields}:
92
- - PlanOptions({keyField}) ??
88
+ - If {ResolveRequirement(sourceSchema, targetSchema, type, keyField)} returns false
89
+ - // Continue to the next {lookup}
90
+ - return true
93
91
- return false
94
92
95
- ResolveRequirement(schema , type, field):
93
+ ResolveRequirement(currentSchema, candidateSchema , type, field):
96
94
- Let {requirements} be the parsed selection map from requirements on {field}
97
- - Let {otherSchemas} be the set of all source schemas excluding {schema }
95
+ - Let {otherSchemas} be the set of all source schemas excluding {candidateSchema} and {currentSchema }
98
96
- For each {requiredField} in {requirements}:
99
97
- Let {fieldPath} be the path to {requiredField} starting from {type}
100
98
- Let {canResolve} be false
99
+ - If {currentSchema} defines {type} and {fieldPath}
100
+ - If {PlanOptionsInternal(fieldPath, [ currentSchema] )} returns an non empty set
101
+ - Set {canResolve} to true
101
102
- For each {otherSchema} in {otherSchemas}:
102
103
- If {otherSchema} defines {type} and {fieldPath}
103
- - If {IsReachable(schema, otherSchema, type)} returns true
104
- - Set {canResolve} to true
105
- - Break
104
+ - // IsReachable
105
+ - If {PlanOptionsInternal(fieldPath, [ currentSchema] )} returns an non empty set
106
+ - Set {canResolve} to true
107
+ - Break
106
108
- If {canResolve} is false
107
109
- return false
108
110
- return true
109
111
112
+ Notes:
113
+ { user { profile { name id }} }
114
+ user.profile.name
115
+ user.profile.id
116
+ user.profile.id -> UserSerivce
117
+ profile.name -> ProfileService through a Lookup on user
110
118
0 commit comments