public static DocumentNode SerializeSchema( ISchema schema, bool includeSpecScalars = false, bool printResolverKind = false) { if (schema is null) { throw new ArgumentNullException(nameof(schema)); } var typeDefinitions = GetNonScalarTypes(schema) .Select(t => SerializeNonScalarTypeDefinition(t, printResolverKind)) .OfType <IDefinitionNode>() .ToList(); if (schema.QueryType is not null || schema.MutationType is not null || schema.SubscriptionType is not null) { typeDefinitions.Insert(0, SerializeSchemaTypeDefinition(schema)); } var builtInDirectives = new HashSet <NameString> { Skip, Include, Deprecated }; IEnumerable <DirectiveDefinitionNode> directiveTypeDefinitions = schema.DirectiveTypes .Where(directive => !builtInDirectives.Contains(directive.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeDirectiveTypeDefinition); typeDefinitions.AddRange(directiveTypeDefinitions); IEnumerable <ScalarTypeDefinitionNode> scalarTypeDefinitions = schema.Types .OfType <ScalarType>() .Where(t => includeSpecScalars || !BuiltInTypes.IsBuiltInType(t.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeScalarType); typeDefinitions.AddRange(scalarTypeDefinitions); return(new DocumentNode(null, typeDefinitions)); }
private static void CrossEntities(IEnumerable <EntityRecommendation> entities) { // Cross match entities to copy resolution values for custom entities from pairs foreach (var group in entities.GroupBy(e => e.Entity)) { if (group.Count() > 1) { var entityToUpdate = group.FirstOrDefault(e => !BuiltInTypes.IsBuiltInType(e.Type)); var entityWithValue = group.FirstOrDefault(e => e.Resolution != null); if (entityToUpdate != null && entityWithValue != null) { entityToUpdate.Resolution = entityWithValue.Resolution; } } } }
public static DocumentNode SerializeSchema( ISchema schema, bool includeSpecScalars = false) { if (schema is null) { throw new ArgumentNullException(nameof(schema)); } var typeDefinitions = GetNonScalarTypes(schema) .Select(SerializeNonScalarTypeDefinition) .OfType <IDefinitionNode>() .ToList(); if (schema.QueryType != null || schema.MutationType != null || schema.SubscriptionType != null) { typeDefinitions.Insert(0, SerializeSchemaTypeDefinition(schema)); } IEnumerable <DirectiveDefinitionNode> directiveTypeDefinitions = schema.DirectiveTypes .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeDirectiveTypeDefinition); typeDefinitions.AddRange(directiveTypeDefinitions); IEnumerable <ScalarTypeDefinitionNode> scalarTypeDefinitions = schema.Types .OfType <ScalarType>() .Where(t => includeSpecScalars || !BuiltInTypes.IsBuiltInType(t.Name)) .OrderBy(t => t.Name.ToString(), StringComparer.Ordinal) .Select(SerializeScalarType); typeDefinitions.AddRange(scalarTypeDefinitions); return(new DocumentNode(null, typeDefinitions)); }