-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8de831
commit cfa95cf
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
32 changes: 32 additions & 0 deletions
32
src/VirtoCommerce.Xapi.Core/Infrastructure/ScopedSchemaFactory.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using GraphQL.Introspection; | ||
|
||
namespace VirtoCommerce.Xapi.Core.Infrastructure | ||
{ | ||
public class ScopedSchemaFactory<TMarker> : SchemaFactory | ||
{ | ||
public ScopedSchemaFactory( | ||
IEnumerable<ISchemaBuilder> schemaBuilders, | ||
IServiceProvider services, | ||
ISchemaFilter schemaFilter) | ||
: base(schemaBuilders, services, schemaFilter) | ||
{ | ||
} | ||
|
||
protected override List<ISchemaBuilder> GetSchemaBuilders() | ||
{ | ||
var schemaBuilders = base.GetSchemaBuilders(); | ||
|
||
// find all builders with inside this project | ||
var currentAssembly = typeof(TMarker).Assembly; | ||
|
||
var subSchemaBuilders = schemaBuilders | ||
.Where(p => p.GetType().Assembly == currentAssembly) | ||
.ToList(); | ||
|
||
return subSchemaBuilders; | ||
} | ||
} | ||
} |