@@ -123,11 +123,6 @@ class SchemaIndex {
123
123
folly::F14FastMap<std::string_view, DefinitionKeyRef>;
124
124
DefinitionKeysByUri definitionKeysByUri_;
125
125
126
- // A set of unresolved definition keys collected while updating indexes.
127
- // This can be used to detect missing definitions in selective resolver.
128
- folly::F14FastSet<DefinitionKeyRef, DefinitionKeyHash, DefinitionKeyEqual>
129
- unresolvedDefinitionRefs_;
130
-
131
126
void updateProgramsById (
132
127
ProgramsById&, const type::Schema&, const DefinitionsByKey&);
133
128
void updateValuesById (ValuesById&, const type::Schema& schema);
@@ -201,13 +196,9 @@ class SchemaIndex {
201
196
* definitions are lazily resolved. This means that it's safe to call
202
197
* typeOf(...) even if the pointed-to type has not been seen yet.
203
198
*/
204
- TypeRef typeOf (const type::TypeStruct&);
205
- TypeRef typeOf (const type::Type& type) { return typeOf (type.toThrift ()); }
206
-
207
- template <typename T>
208
- detail::Lazy<T> createLazyUnresolved (const type::DefinitionKey& key) {
209
- unresolvedDefinitionRefs_.insert (key);
210
- return typename detail::Lazy<T>::Unresolved (resolver_, key);
199
+ TypeRef typeOf (const type::TypeStruct&) const ;
200
+ TypeRef typeOf (const type::Type& type) const {
201
+ return typeOf (type.toThrift ());
211
202
}
212
203
213
204
Resolver& resolver_;
@@ -219,31 +210,20 @@ class SchemaIndex {
219
210
const DefinitionNode* definitionForUri (std::string_view uri) const ;
220
211
ProgramNode::IncludesList programs () const ;
221
212
222
- void updateIndices (const type::Schema& schema, bool resolve = false ) {
213
+ void updateIndices (const type::Schema& schema) {
223
214
updateDefinitionsByKey (
224
215
definitionsByKey_, schema, createProgramIdsByDefinitionKey (schema));
225
216
updateProgramsById (programsById_, schema, definitionsByKey_);
226
217
updateValuesById (valuesById_, schema);
227
218
updateDefinitionKeysByUri (definitionKeysByUri_, definitionsByKey_);
228
-
229
- auto unresolved = std::move (unresolvedDefinitionRefs_);
230
- if (!resolve) {
231
- return ;
232
- }
233
- for (const auto & keyRef : unresolved) {
234
- if (!definitionsByKey_.contains (keyRef)) {
235
- folly::throw_exception<InvalidSyntaxGraphError>(
236
- " There are unresolved definitions." );
237
- }
238
- }
239
219
}
240
220
};
241
221
242
222
class FullyResolvedSchemaRefBackedResolver : public SchemaBackedResolver {
243
223
public:
244
224
explicit FullyResolvedSchemaRefBackedResolver (const type::Schema& schema)
245
225
: schema_(schema) {
246
- index_->updateIndices (schema_, true );
226
+ index_->updateIndices (schema_);
247
227
}
248
228
249
229
const ProgramNode& programOf (const type::ProgramId& id) const override {
@@ -268,7 +248,7 @@ class FullyResolvedSchemaBackedResolver : public SchemaBackedResolver {
268
248
public:
269
249
explicit FullyResolvedSchemaBackedResolver (type::Schema&& schema)
270
250
: schema_(std::move(schema)) {
271
- index_->updateIndices (schema_, true );
251
+ index_->updateIndices (schema_);
272
252
}
273
253
274
254
const ProgramNode& programOf (const type::ProgramId& id) const override {
@@ -363,7 +343,7 @@ const type::DefinitionKey& SchemaIndex::definitionKeyOf(
363
343
}
364
344
}
365
345
366
- TypeRef SchemaIndex::typeOf (const type::TypeStruct& type) {
346
+ TypeRef SchemaIndex::typeOf (const type::TypeStruct& type) const {
367
347
return TypeRef ([&]() -> TypeRef::Alternative {
368
348
using T = type::TypeName::Type;
369
349
T t = type.name ()->getType ();
@@ -387,20 +367,20 @@ TypeRef SchemaIndex::typeOf(const type::TypeStruct& type) {
387
367
case T::binaryType:
388
368
return Primitive::BINARY;
389
369
case T::enumType:
390
- return createLazyUnresolved <EnumNode>(
391
- definitionKeyOf (*type.name ()->enumType ()));
370
+ return detail::Lazy <EnumNode>:: Unresolved (
371
+ resolver_, definitionKeyOf (*type.name ()->enumType ()));
392
372
case T::typedefType:
393
- return createLazyUnresolved <TypedefNode>(
394
- definitionKeyOf (*type.name ()->typedefType ()));
373
+ return detail::Lazy <TypedefNode>:: Unresolved (
374
+ resolver_, definitionKeyOf (*type.name ()->typedefType ()));
395
375
case T::structType:
396
- return createLazyUnresolved <StructNode>(
397
- definitionKeyOf (*type.name ()->structType ()));
376
+ return detail::Lazy <StructNode>:: Unresolved (
377
+ resolver_, definitionKeyOf (*type.name ()->structType ()));
398
378
case T::unionType:
399
- return createLazyUnresolved <UnionNode>(
400
- definitionKeyOf (*type.name ()->unionType ()));
379
+ return detail::Lazy <UnionNode>:: Unresolved (
380
+ resolver_, definitionKeyOf (*type.name ()->unionType ()));
401
381
case T::exceptionType:
402
- return createLazyUnresolved <ExceptionNode>(
403
- definitionKeyOf (*type.name ()->exceptionType ()));
382
+ return detail::Lazy <ExceptionNode>:: Unresolved (
383
+ resolver_, definitionKeyOf (*type.name ()->exceptionType ()));
404
384
case T::listType: {
405
385
const auto & params = *type.params ();
406
386
if (params.size () != 1 ) {
@@ -717,8 +697,8 @@ FunctionNode SchemaIndex::createFunction(
717
697
auto interaction = [&]() -> std::optional<detail::Lazy<InteractionNode>> {
718
698
if (const auto & interactionTypeUri = *function.interactionType ()->uri ();
719
699
!isEmptyTypeUri (interactionTypeUri)) {
720
- return createLazyUnresolved <InteractionNode>(
721
- definitionKeyOf (interactionTypeUri));
700
+ return detail::Lazy <InteractionNode>:: Unresolved (
701
+ resolver_, definitionKeyOf (interactionTypeUri));
722
702
}
723
703
return std::nullopt;
724
704
}();
0 commit comments