Skip to content

Commit 1a37da1

Browse files
committed
working commit
1 parent 5536a82 commit 1a37da1

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

spec/Section 5 -- Execution.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ Mutation.createUser.query.me
4040

4141

4242
PlanOptions(path):
43-
44-
4543
- Let {pathElements} be the list of tuples ({type}, {field}) in the provided {path}.
4644

4745
- Let ({initialType}, {initialField}) be the first element in {pathElements}.
@@ -52,6 +50,7 @@ PlanOptions(path):
5250
- Continue to the next {sourceSchema}.
5351
- Add {sourceSchema} to {sourceSchemas}.
5452

53+
PlanOptionsInternal(path, sourceSchemas):
5554
- For each {pathElement} in {pathElements} starting from the second element:
5655
- Initialize a new empty set {nextSchemas}.
5756
- Set {currentType} and {currentField} to the respective elements of the current {pathElement}.
@@ -61,17 +60,16 @@ PlanOptions(path):
6160
- Continue to the next {candidateSchema}.
6261

6362
- 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}.
6765

6866
- 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:
7168
- Continue to the next {candidateSchema}.
69+
7270
- Add {candidateSchema} to {nextSchemas}.
7371

74-
- If {nextSchemas} is empty after:
72+
- If {nextSchemas} is empty:
7573
- Return an empty set.
7674

7775
- Set {sourceSchemas} equal to {nextSchemas} to proceed to the next element in the path.
@@ -82,29 +80,39 @@ IsReachable(sourceSchema, targetSchema, type):
8280
- If {targetSchema} does not define {type}
8381
- return false
8482
- If {sourceSchema} equals {targetSchema}
85-
- return true
83+
- Assert: TODO This should be a precondition
8684
- Let {lookups} be the set of all lookup fields in {targetSchema} that return {type}
8785
- For each {lookup} in {lookups}:
8886
- Let {keyFields} be the set of fields that form the key for {lookup} in {targetSchema}
89-
- If {keyFields} is empty
90-
- return false // ??
9187
- 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
9391
- return false
9492

95-
ResolveRequirement(schema, type, field):
93+
ResolveRequirement(currentSchema, candidateSchema, type, field):
9694
- 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}
9896
- For each {requiredField} in {requirements}:
9997
- Let {fieldPath} be the path to {requiredField} starting from {type}
10098
- 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
101102
- For each {otherSchema} in {otherSchemas}:
102103
- 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
106108
- If {canResolve} is false
107109
- return false
108110
- return true
109111

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
110118

0 commit comments

Comments
 (0)