# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['simple_graphql',
 'simple_graphql.auth',
 'simple_graphql.auth.migrations',
 'simple_graphql.django',
 'simple_graphql.django.fields',
 'simple_graphql.django.schema']

package_data = \
{'': ['*']}

install_requires = \
['django-filter>=2.4.0,<3.0.0', 'graphene-django>=2.15.0,<3.0.0']

setup_kwargs = {
    'name': 'django-simple-graphql',
    'version': '0.3.0',
    'description': 'A stupid simple GraphQL setup for Django',
    'long_description': '# django-simple-graphql\n\nA stupid simple GraphQL setup for Django\n\n**This project is still a WIP and will receive breaking changes**\n\n## TODO\n\n- Support mutations\n- Support subscriptions\n- An easy default for authentication\n- Account for reverse-relations automatically\n- Handle django-graphene issue with relations ponting to non-pk fields and ID encoding\n- Configurability\n  - Custom set of node interfaces (currently relay.Node)\n  - Custom relation connection handler (currently DjangoFilterConnectionField)\n  - Custom node/query/mutation/subscription builder functions\n  - Custom schema member naming\n  - Custom search\n  - Enable/disable search globally\n  - Enable/disable ordering globally\n  - Global default ordering options\n  - Injection of GraphQL ID property to models, configurable name and/or disable\n- Examples\n- More lax version pinning (Min python 3.5 or higher)\n- Test suite against multiple version configurations\n- Proper readme\n- Better type definitions\n- GraphQL schema docstring generation\n- Validation checks when building the schema to prevent blatantly incorrect config\n  - For example, a field in search fields that doesn\'t exist or isn\'t supported\n- Perhaps a way to auto-render the schema for github diffs?\n- A way to easily include extra queries for models (e.g. with different filters)\n- Require either field exclusions or inclusions to be explicitly defined\n- Build a namespace package instead of a normal one (use "simple_graphql" as namespace root)\n- Don\'t be as tightly coupled with graphene\n  - e.g. support to https://github.com/strawberry-graphql/strawberry would be nice\n- Automatic CRUD operations\n- Support more complex ordering options (as well as explicit naming of ordering)\n- Run tests for code included in documentation\n- Support for permissions\n- Query cost analysis / rate limiting\n- Consider supporting an alternative approach where registration decorator\n  could be applied to a GraphQL config object instead of the model class\n- Allow the register decorator be used with or without function call. Possibly\n  also allow it\'s use as a non-decorator registering function.\n- Add support for using the schema builder if there\'s need to combine with an\n  existing graphene schema declaration.\n\n\n## Features (already supported)\n\nTODO: Improve the documentation\n\n- Enable GraphQL queries for Django models with a decorator\n  - By default, includes a `getModelName` and `listModelName` queries\n  - Configure by adding a `GraphQL` meta class to the model class\n  - Alternatively supply a configuration class to the decorator\n- Supported configuration options\n  - `filters`: A `django-filter` compatible set of filters supported on the\n    model\'s QuerySet. List or a Dictionary.\n  - `exclude_fields`: A list of field names to exclude from the schema\n  - `search_fields`: A list of fields to perform search on\n  - `ordering_fields`: A list of fields that can be used to order results\n  - `default_ordering`: What ordering to use if none was specified\n- Adds a `graphql_node_name` field to model classes\n- Adds a `graphql_id` property to models, which can be used to retrieve the\n  Global ID of a model instance.\n\n## Usage\n\n### Setup\n\nSteps 1-3 are setup for `graphene-django`.\nSee https://docs.graphene-python.org/projects/django/en/latest/installation/ for\nmore details.\n\nIf you are already using `graphene-django`, you can skip to step 4.\n\n1. Add `graphene-django` to your `INSTALLED_APPS`:\n   ```python\n   INSTALLED_APPS = [\n       # ...\n       "django.contrib.staticfiles", # Required for GraphiQL\n       "graphene_django",\n   ]\n   ```\n2. Add a GraphQL endpoint to the URL config:\n   ```python\n   from django.urls import path\n   from django.views.decorators.csrf import csrf_exempt\n\n   from graphene_django.views import GraphQLView\n\n   urlpatterns = [\n       # ...\n       path("graphql", csrf_exempt(GraphQLView.as_view(graphiql=True))),\n   ]\n   ```\n3. Create a schema file (e.g. `schema.py`) and configure it to Graphene:\n   ```python\n   # settings.py\n   GRAPHENE = {\n       "SCHEMA": "myapp.shcema.schema",\n   }\n   ```\n4. Declare the schema in your schema file\n   ```python\n   # schema.py\n   from simple_graphql.django import Schema\n\n   schema = Schema()\n   ```\n\n\n### Default queries\n\nBy default, all model classes registered to the schema will get a query for\nfetching a single object by ID as well as a list query.\n\nFor the sake of an example, let\'s say we have the following model declaration:\n\n```python\nfrom django.db import models\n\nfrom myapp.schema import schema\n\n@schema.graphql_model()\nclass Person(models.Model):\n    first_name = models.TextField()\n    last_name = models.TextField()\n```\n\nThe `graphql_model` decorator will add the model to our GraphQL schema builder,\nwhich will build it into the following schema (relay schema omitted):\n\n```graphql\ntype Person implements Node {\n  id: ID!\n  lastName: String!\n  firstName: String!\n}\n\ntype Query {\n  getPerson(id: ID!): Person\n  listPerson(after: String, before: String, first: Int, last: Int, offset: Int): PersonConnection\n}\n```\n\nFor a more complete example of the generated schema, see\n[example/schema.graphql](example/schema.graphql)\n\n### Search\n\nTODO\n\n## Examples\n\n### Registering models\n\nThere\'s two ways models can be added to the schema\n\n#### With a class decorator\n\n```python\nfrom django.db import models\n\nfrom myapp.schema import schema\n\n@schema.graphql_model()\nclass Person(models.Model):\n    first_name = models.TextField()\n    last_name = models.TextField()\n```\n\n#### With a function call\n\n```python\nfrom django.contrib.auth import get_user_model\n\nfrom myapp.schema import schema\n\nUser = get_user_model()\n\nschema.register_model(User)\n```\n\n### Configuring models\n\nModel specific schemas can be configured either with a metaclass or passed in\nas a parameter. A base configuration also is present regardless of custom\ndeclarations.\n\nIf multiple configurations are present, they will be merged in the following\nprecedence:\n\n1. Configuration supplied via parameters\n2. Metaclass based configuration\n3. Default configuration\n\nWhere lower number means higher priority.\n\n#### Metaclass configuration\n\n```python\nfrom django.db import models\n\nfrom myapp.schema import schema\n\n@schema.graphql_model()\nclass Person(models.Model):\n    first_name = models.TextField()\n    last_name = models.TextField()\n    credit_card_number = models.TextField()\n    parent = models.ForeignKey("self", on_delete=models.SET_NULL)\n\n    class GraphQL:\n        exclude_fields = ["credit_card_number"]\n        ordering_fields = ["first_name", "last_name"]\n        default_ordering = ["first_name"]\n        search_fields = ["first_name", "last_name"]\n        filters = ["parent"]\n```\n\n#### Parameter configuration (with a class)\n\n```python\nfrom django.db import models\n\nfrom myapp.schema import schema\n\n\nclass PersonGraphQLConfig:\n    exclude_fields = ["credit_card_number"]\n    ordering_fields = ["first_name", "last_name"]\n    default_ordering = ["first_name"]\n    search_fields = ["first_name", "last_name"]\n    filters = ["parent"]\n\n\n@schema.graphql_model(PersonGraphQLConfig)\nclass Person(models.Model):\n    first_name = models.TextField()\n    last_name = models.TextField()\n    credit_card_number = models.TextField()\n    parent = models.ForeignKey("self", on_delete=models.SET_NULL)\n```\n\n#### Parameter configuration (with a config object)\n\n```python\nfrom django.db import models\n\nfrom simple_graphql.django import ModelSchemaConfig\n\nfrom myapp.schema import schema\n\n\n@schema.graphql_model(ModelSchemaConfig(\n    exclude_fields=["credit_card_number"],\n    ordering_fields=["first_name", "last_name"],\n    default_ordering=["first_name"],\n    search_fields=["first_name", "last_name"],\n    filters=["parent"],\n))\nclass Person(models.Model):\n    first_name = models.TextField()\n    last_name = models.TextField()\n    credit_card_number = models.TextField()\n    parent = models.ForeignKey("self", on_delete=models.SET_NULL)\n```\n\n#### Parameter configuration (function variant)\n\n```python\nfrom django.contrib.auth import get_user_model\n\nfrom simple_graphql.django import ModelSchemaConfig\n\nfrom myapp.schema import schema\n\nUser = get_user_model()\n\n# Could also use a class here just like with the decorator\nschema.register_model(User, ModelSchemaConfig(\n    exclude_fields=["password"],\n))\n```\n',
    'author': 'Joa Riski',
    'author_email': 'joa.riski@riskidev.fi',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/JoaRiski/django-simple-graphql',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
