Skip to content

Commit

Permalink
fix(index): ability to do indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Mar 8, 2024
1 parent b30cf05 commit 7cd68d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 0 additions & 3 deletions arches_orm/graphql/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ async def mutate_bulk_create(parent, info, mutation, resource_cls, field_sets, d

async def mutate_create(parent, info, mutation, resource_cls, field_set, do_index=True):
# FIXME: proper authorization
print(context.data["user"])
if not ALLOW_ANONYMOUS and not context.data["user"].is_superuser:
return {
snake(resource_cls.__name__): None,
Expand All @@ -523,8 +522,6 @@ async def mutate_create(parent, info, mutation, resource_cls, field_set, do_inde

resource = _build_resource(resource_cls, **field_set)
await sync_to_async(resource.to_resource)()
if do_index:
await sync_to_async(resource.index)()
ok = True
kwargs = {
snake(resource_cls.__name__): resource,
Expand Down
6 changes: 6 additions & 0 deletions arches_orm/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ def update(self, values: dict):
for key, val in values.items():
setattr(self, key, val)

def index(self):
"""Index the underlying resource."""
resource = self.to_resource(strict=True, _no_save=False)
resource.index()
return self

def save(self):
"""Rebuild and save the underlying resource."""
resource = self.to_resource(strict=True, _no_save=False)
Expand Down

0 comments on commit 7cd68d2

Please sign in to comment.