Skip to content

Commit ce81ebb

Browse files
pmantica1bojanserafimov
authored andcommitted
Fix index documentation (kensho-technologies#321)
* Fix index documentation * Nit
1 parent 2007db1 commit ce81ebb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

graphql_compiler/schema_generation/schema_graph.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
)
2727

2828

29+
ILLEGAL_PROPERTY_NAMES = (
30+
# Names we reserve for referencing base connections as fields of an IndexDefinition object.
31+
'out',
32+
'in',
33+
)
34+
35+
2936
class SchemaGraph(object):
3037
"""The SchemaGraph is a graph utility used to represent a OrientDB schema.
3138
@@ -419,7 +426,12 @@ def _validate_non_abstract_edge_has_defined_base_connections(
419426
def _validate_property_names(class_name, properties):
420427
"""Validate that properties do not have names that may cause problems in the GraphQL schema."""
421428
for property_name in properties:
422-
if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES):
429+
is_illegal_name = (
430+
not property_name or
431+
property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES) or
432+
property_name in ILLEGAL_PROPERTY_NAMES
433+
)
434+
if is_illegal_name:
423435
raise IllegalSchemaStateError(u'Class "{}" has a property with an illegal name: '
424436
u'{}'.format(class_name, property_name))
425437

@@ -583,7 +595,9 @@ def link_schema_elements(elements, inheritance_structure):
583595
# A way to describe an index:
584596
# - name: string, the name of the index.
585597
# - base_classname: string, the name of the class on which the index is defined.
586-
# - fields: set of strings, the set of fields which the index encompasses.
598+
# - fields: set of strings, indicating which objects the index encompasses.
599+
# The 'in' and 'out' strings refer to the base connections.
600+
# All other strings reference the base class's properties.
587601
# - unique: bool, indicating whether this index is unique.
588602
# - ordered: bool, indicating whether this index is ordered.
589603
# - ignore_nulls: bool, indicating if the index ignores null values.

0 commit comments

Comments
 (0)