Skip to content

Commit

Permalink
restructure folder layout to make it easier to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianCzajkowski committed Aug 22, 2024
1 parent 3da5fc3 commit 6b98c66
Show file tree
Hide file tree
Showing 494 changed files with 7,323 additions and 6,591 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Pytest
run: |
pytest
- name: Linters
run: |
pylint ariadne_graphql_modules tests
mypy ariadne_graphql_modules --ignore-missing-imports
black --check .
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Pytest
run: |
pytest
- name: Linters
run: |
pylint ariadne_graphql_modules
mypy ariadne_graphql_modules --ignore-missing-imports
black --check .
86 changes: 53 additions & 33 deletions ariadne_graphql_modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,58 @@
from ariadne import gql

from .bases import BaseType, BindableType, DeferredType, DefinitionType
from .collection_type import CollectionType
from .convert_case import convert_case
from .directive_type import DirectiveType
from .enum_type import EnumType
from .base import GraphQLMetadata, GraphQLModel, GraphQLType
from .convert_name import (
convert_graphql_name_to_python,
convert_python_name_to_graphql,
)
from .deferredtype import deferred
from .description import get_description_node
from .enum_type import (
GraphQLEnum,
GraphQLEnumModel,
create_graphql_enum_model,
graphql_enum,
)
from .executable_schema import make_executable_schema
from .input_type import InputType
from .interface_type import InterfaceType
from .mutation_type import MutationType
from .object_type import ObjectType
from .scalar_type import ScalarType
from .subscription_type import SubscriptionType
from .union_type import UnionType
from .utils import create_alias_resolver, parse_definition
from .idtype import GraphQLID
from .input_type import GraphQLInput, GraphQLInputModel
from .object_type import GraphQLObject, GraphQLObjectModel, object_field
from .roots import ROOTS_NAMES, merge_root_nodes
from .scalar_type import GraphQLScalar, GraphQLScalarModel
from .sort import sort_schema_document
from .union_type import GraphQLUnion, GraphQLUnionModel
from .value import get_value_from_node, get_value_node
from .interface_type import GraphQLInterface, GraphQLInterfaceModel
from .subscription_type import GraphQLSubscription, GraphQLSubscriptionModel

__all__ = [
"BaseType",
"BindableType",
"CollectionType",
"DeferredType",
"DefinitionType",
"DirectiveType",
"EnumType",
"InputType",
"InterfaceType",
"MutationType",
"ObjectType",
"ScalarType",
"SubscriptionType",
"UnionType",
"convert_case",
"create_alias_resolver",
"gql",
"GraphQLEnum",
"GraphQLEnumModel",
"GraphQLID",
"GraphQLInput",
"GraphQLInputModel",
"GraphQLInterface",
"GraphQLInterfaceModel",
"GraphQLSubscription",
"GraphQLSubscriptionModel",
"GraphQLMetadata",
"GraphQLModel",
"GraphQLObject",
"GraphQLObjectModel",
"GraphQLScalar",
"GraphQLScalarModel",
"GraphQLType",
"GraphQLUnion",
"GraphQLUnionModel",
"ROOTS_NAMES",
"convert_graphql_name_to_python",
"convert_python_name_to_graphql",
"create_graphql_enum_model",
"deferred",
"get_description_node",
"get_value_from_node",
"get_value_node",
"graphql_enum",
"make_executable_schema",
"parse_definition",
"merge_root_nodes",
"object_field",
"sort_schema_document",
]
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_graphql_model(
if hasattr(graphql_type, "__get_graphql_model__"):
self.models[graphql_type] = graphql_type.__get_graphql_model__(self)
elif issubclass(graphql_type, Enum):
from .graphql_enum_type import ( # pylint: disable=R0401,C0415
from .enum_type import ( # pylint: disable=R0401,C0415
create_graphql_enum_model,
)

Expand Down
15 changes: 15 additions & 0 deletions ariadne_graphql_modules/base_object_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .graphql_type import GraphQLBaseObject
from .graphql_field import GraphQLFieldData, GraphQLObjectData
from .validators import (
validate_object_type_with_schema,
validate_object_type_without_schema,
)


__all__ = [
"GraphQLBaseObject",
"GraphQLObjectData",
"GraphQLFieldData",
"validate_object_type_with_schema",
"validate_object_type_without_schema",
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional
from ariadne.types import Resolver, Subscriber


Expand All @@ -12,6 +12,47 @@ class GraphQLObjectFieldArg:
default_value: Optional[Any] = None


@dataclass(frozen=True)
class GraphQLObjectData:
fields: Dict[str, "GraphQLObjectField"]
interfaces: List[str]


@dataclass(frozen=True)
class GraphQLObjectResolver:
resolver: Resolver
field: str
description: Optional[str] = None
args: Optional[Dict[str, GraphQLObjectFieldArg]] = None
field_type: Optional[Any] = None


@dataclass(frozen=True)
class GraphQLObjectSource:
subscriber: Subscriber
field: str
description: Optional[str] = None
args: Optional[Dict[str, GraphQLObjectFieldArg]] = None
field_type: Optional[Any] = None


@dataclass
class GraphQLFieldData:
fields_types: Dict[str, str] = field(default_factory=dict)
fields_names: Dict[str, str] = field(default_factory=dict)
fields_descriptions: Dict[str, str] = field(default_factory=dict)
fields_args: Dict[str, Dict[str, GraphQLObjectFieldArg]] = field(
default_factory=dict
)
fields_resolvers: Dict[str, Resolver] = field(default_factory=dict)
fields_subscribers: Dict[str, Subscriber] = field(default_factory=dict)
fields_defaults: Dict[str, Any] = field(default_factory=dict)
fields_order: List[str] = field(default_factory=list)
type_hints: Dict[str, Any] = field(default_factory=dict)
aliases: Dict[str, str] = field(default_factory=dict)
aliases_targets: List[str] = field(default_factory=list)


class GraphQLObjectField:
def __init__(
self,
Expand Down Expand Up @@ -40,24 +81,6 @@ def __call__(self, resolver: Resolver):
return self


@dataclass(frozen=True)
class GraphQLObjectResolver:
resolver: Resolver
field: str
description: Optional[str] = None
args: Optional[Dict[str, GraphQLObjectFieldArg]] = None
field_type: Optional[Any] = None


@dataclass(frozen=True)
class GraphQLObjectSource:
subscriber: Subscriber
field: str
description: Optional[str] = None
args: Optional[Dict[str, GraphQLObjectFieldArg]] = None
field_type: Optional[Any] = None


def object_field(
resolver: Optional[Resolver] = None,
*,
Expand Down
Loading

0 comments on commit 6b98c66

Please sign in to comment.