Skip to content

Commit

Permalink
Merge pull request #87 from chanzuckerberg/ninabernick/repo_structure
Browse files Browse the repository at this point in the history
update repo structure
  • Loading branch information
ninabernick authored Jul 26, 2024
2 parents ec383ea + ac937a0 commit 5e512d2
Show file tree
Hide file tree
Showing 32 changed files with 95 additions and 136 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,13 @@ pyrightconfig.json
.env.localdev

# Codegen on test app
test_app/api/*
test_app/graphql_api/*
test_app/database/*
test_app/cerbos/*
test_app/support/*
test_app/test_infra/*
test_app/.moto_recording
test_app/validators/*

# temp files
/tmp/*
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
rev: "v1.10.0"
hooks:
- id: mypy
exclude: "platformics/thirdparty|platformics/api/relay"
exclude: "platformics/thirdparty|platformics/graphql_api/relay"
additional_dependencies: ["types-PyYAML", "types-dateparser", "types-requests"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand Down
42 changes: 0 additions & 42 deletions docker-compose-dev.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/HOWTO-working-with-platformics.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Notable files and subdirectories:
* `api/` - entrypoint for GQL API service
* `helpers/` - generated GQL types and helper functions for GROUPBY queries
* `types/` - generated GQL types
* `validators/` - generated Pydantic validators for create and update inputs
* `mutations.py` - generated mutations (create, update, delete) for each entity type
* `queries.py` - generated queries (list and aggregate) for each entity type
* `schema.graphql` - GQL format schema
* `schema.json` - JSON format schema
* `validators/` - generated Pydantic validators for create and update inputs
* `cerbos/` - generated access policies for user actions for each entity type
* `database/` - code related to establishing DB connections / sessions
* `migrations/` - alembic migrations
Expand Down
16 changes: 8 additions & 8 deletions platformics/codegen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

DIR_CODEGEN = [
"support",
"api/types",
"api/validators",
"api/helpers",
"graphql_api/types",
"graphql_api/helpers",
"database/models",
"database/migrations",
"database/migrations/versions",
"cerbos/policies",
"cerbos/policies/_schemas",
"test_infra/factories",
"validators",
]


Expand Down Expand Up @@ -106,8 +106,8 @@ def generate_entity_import_files(
"database/models/__init__.py",
"database/migrations/env.py",
"database/migrations/script.py.mako",
"api/queries.py",
"api/mutations.py",
"graphql_api/queries.py",
"graphql_api/mutations.py",
]
classes = view.entities
for filename in import_templates:
Expand Down Expand Up @@ -156,14 +156,14 @@ def generate(schemafile: str, output_prefix: str, render_files: bool, template_o
)
generate_entity_subclass_files(
output_prefix,
"api/types/class_name.py",
"graphql_api/types/class_name.py",
environment,
wrapped_view,
render_files=render_files,
)
generate_entity_subclass_files(
output_prefix,
"api/validators/class_name.py",
"validators/class_name.py",
environment,
wrapped_view,
render_files=render_files,
Expand All @@ -184,7 +184,7 @@ def generate(schemafile: str, output_prefix: str, render_files: bool, template_o
)
generate_entity_subclass_files(
output_prefix,
"api/helpers/class_name.py",
"graphql_api/helpers/class_name.py",
environment,
wrapped_view,
render_files=render_files,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Define GraphQL types and helper functions for supporting GROUPBY queries.

Auto-gereanted by running 'make codegen'. Do not edit.
Make changes to the template codegen/templates/api/groupby_helpers.py.j2 instead.
Make changes to the template codegen/templates/graphql_api/groupby_helpers.py.j2 instead.
"""
{% set related_fields = cls.related_fields | unique(attribute='related_class.name') | list %}
{% set ignored_fields = ["File", "Entity", cls.name] %}
Expand All @@ -23,7 +23,7 @@ from support.enums import

{%- for field in cls.related_fields %}
{%- if field.related_class.name not in ignored_fields and not field.multivalued and not field.is_virtual_relationship %}
from api.helpers.{{ field.related_class.snake_name }} import {{ field.related_class.name }}GroupByOptions, build_{{ field.related_class.snake_name }}_groupby_output
from graphql_api.helpers.{{ field.related_class.snake_name }} import {{ field.related_class.name }}GroupByOptions, build_{{ field.related_class.snake_name }}_groupby_output
{%- endif %}
{%- endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
GraphQL mutations for files and entities

Auto-generated by running 'make codegen'. Do not edit.
Make changes to the template codegen/templates/api/mutations.py.j2 instead.
Make changes to the template codegen/templates/graphql_api/mutations.py.j2 instead.
"""

import strawberry
from typing import Sequence
{%- if render_files %}
from platformics.api.files import File, create_file, upload_file, upload_temporary_file, mark_upload_complete, concatenate_files, SignedURL, MultipartUploadResponse
from platformics.graphql_api.files import File, create_file, upload_file, upload_temporary_file, mark_upload_complete, concatenate_files, SignedURL, MultipartUploadResponse
{%- endif %}

{%- for class in classes %}
from api.types.{{ class.snake_name }} import {{ class.name }}, {%- if class.create_fields %}create_{{ class.snake_name }}, {%- endif %}{%- if class.mutable_fields %}update_{{ class.snake_name }}, {%- endif %}delete_{{ class.snake_name }}
from graphql_api.types.{{ class.snake_name }} import {{ class.name }}, {%- if class.create_fields %}create_{{ class.snake_name }}, {%- endif %}{%- if class.mutable_fields %}update_{{ class.snake_name }}, {%- endif %}delete_{{ class.snake_name }}
{%- endfor %}

@strawberry.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
Supported GraphQL queries for files and entities

Auto-generated by running 'make codegen'. Do not edit.
Make changes to the template codegen/templates/api/queries.py.j2 instead.
Make changes to the template codegen/templates/graphql_api/queries.py.j2 instead.
"""

import strawberry
from platformics.api import relay
from platformics.graphql_api import relay
from typing import Sequence, List
{%- if render_files %}
from platformics.api.files import File, resolve_files
from platformics.graphql_api.files import File, resolve_files
{%- endif %}
{%- for class in classes %}
from api.types.{{ class.snake_name }} import {{ class.name }}, resolve_{{ class.plural_snake_name }}, {{ class.name }}Aggregate, resolve_{{ class.plural_snake_name }}_aggregate
from graphql_api.types.{{ class.snake_name }} import {{ class.name }}, resolve_{{ class.plural_snake_name }}, {{ class.name }}Aggregate, resolve_{{ class.plural_snake_name }}_aggregate
{%- endfor %}


Expand Down
Loading

0 comments on commit 5e512d2

Please sign in to comment.