clear-skies-gql


Nameclear-skies-gql JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/cmancone/clearskies-gql
Summaryclearskies bindings for Apollo GQL
upload_time2023-01-24 12:21:03
maintainer
docs_urlNone
authorConor Mancone
requires_python>=3.6
licenseMIT
keywords setuptools development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # clearskies-gql

clearskies bindings for Graph QL.  While this may eventually include handlers to create GQL servers, the current focus is just on a backend to interact with GQL servers.

# Installation, Documentation, and Usage

To install:

```
pip3 install clear-skies-gql
```

# Usage

### Example

Include this in your binding modules, extend it if you need to specify authentication, and then use it in your models.

```
import clearskies
import clearskies_gql

def process_pets_from_gql(pets):
    for pet in pets.where('name=fido'):
        print(pet.species)

class GqlBackendWithAuth(clearskies_gql.backends.GqlBackend):
    def __init__(self, requests, environment, logging, my_auth_method):
        super().__init__(requests, environment, logging)
        self.configure(
            url='https://gql.server.example.com',
            auth=my_auth_method,
        )

class Pet(clearskies.Model):
    def __init__(self, gql_backend_with_auth, columns):
        super().__init__(gql_backend_with_auth, columns)

    def columns_configuration(self):
        return OrderedDict([
            clearskies.column_types.string('name'),
            clearskies.column_types.string('species'),
        ])

process_pets = clearskies.Application(
    clearskies.handlers.Callable,
    {'callable': process_pets_from_gql},
    binding_modules=[clearskies_gql],
    binding_classes=[Pet, GqlBackendWithAuth],
)
```

Then just wire up your application to a context and you're ready to go!

### Record name

`clear-skies-gql` will use the pluralized and snake_case version of the model class name as the descriptor of the records in GQL, e.g. the above model class results in this query:

```
query Query {
  pets {
    name
    species
  }
}
```

But you can override this behavior by specifying the table name for your model, e.g.:

```
class Pet(clearskies.Model):
    def __init__(self, gql_backend_with_auth, columns):
        super().__init__(gql_backend_with_auth, columns)

    @classmethod
    def table_name(cls):
        return 'whateverYouWant'

    def columns_configuration(self):
        return OrderedDict([
            clearskies.column_types.string('name'),
            clearskies.column_types.string('species'),
        ])
```

results in this query:

```
query Query {
  whateverYouWant {
    name
    species
  }
}
```

### Server URL

You can also specify the URL to the GQL server by setting the `gql_server_url` environment variable.  If your gql server doesn't require authentication, then you can use the graphql backend directly:

```
# note: requires the gql_server_url environment variable to point to the server

class Pet(clearskies.Model):
    def __init__(self, gql_backend, columns):
        super().__init__(gql_backend, columns)

    def columns_configuration(self):
        return OrderedDict([
            clearskies.column_types.string('name'),
            clearskies.column_types.string('species'),
        ])
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cmancone/clearskies-gql",
    "name": "clear-skies-gql",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "setuptools development",
    "author": "Conor Mancone",
    "author_email": "cmancone@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/3a/68a231e11e0c71eef535cb968be7cccfaeb96772f095231f8131976e74a0/clear-skies-gql-0.1.2.tar.gz",
    "platform": null,
    "description": "# clearskies-gql\n\nclearskies bindings for Graph QL.  While this may eventually include handlers to create GQL servers, the current focus is just on a backend to interact with GQL servers.\n\n# Installation, Documentation, and Usage\n\nTo install:\n\n```\npip3 install clear-skies-gql\n```\n\n# Usage\n\n### Example\n\nInclude this in your binding modules, extend it if you need to specify authentication, and then use it in your models.\n\n```\nimport clearskies\nimport clearskies_gql\n\ndef process_pets_from_gql(pets):\n    for pet in pets.where('name=fido'):\n        print(pet.species)\n\nclass GqlBackendWithAuth(clearskies_gql.backends.GqlBackend):\n    def __init__(self, requests, environment, logging, my_auth_method):\n        super().__init__(requests, environment, logging)\n        self.configure(\n            url='https://gql.server.example.com',\n            auth=my_auth_method,\n        )\n\nclass Pet(clearskies.Model):\n    def __init__(self, gql_backend_with_auth, columns):\n        super().__init__(gql_backend_with_auth, columns)\n\n    def columns_configuration(self):\n        return OrderedDict([\n            clearskies.column_types.string('name'),\n            clearskies.column_types.string('species'),\n        ])\n\nprocess_pets = clearskies.Application(\n    clearskies.handlers.Callable,\n    {'callable': process_pets_from_gql},\n    binding_modules=[clearskies_gql],\n    binding_classes=[Pet, GqlBackendWithAuth],\n)\n```\n\nThen just wire up your application to a context and you're ready to go!\n\n### Record name\n\n`clear-skies-gql` will use the pluralized and snake_case version of the model class name as the descriptor of the records in GQL, e.g. the above model class results in this query:\n\n```\nquery Query {\n  pets {\n    name\n    species\n  }\n}\n```\n\nBut you can override this behavior by specifying the table name for your model, e.g.:\n\n```\nclass Pet(clearskies.Model):\n    def __init__(self, gql_backend_with_auth, columns):\n        super().__init__(gql_backend_with_auth, columns)\n\n    @classmethod\n    def table_name(cls):\n        return 'whateverYouWant'\n\n    def columns_configuration(self):\n        return OrderedDict([\n            clearskies.column_types.string('name'),\n            clearskies.column_types.string('species'),\n        ])\n```\n\nresults in this query:\n\n```\nquery Query {\n  whateverYouWant {\n    name\n    species\n  }\n}\n```\n\n### Server URL\n\nYou can also specify the URL to the GQL server by setting the `gql_server_url` environment variable.  If your gql server doesn't require authentication, then you can use the graphql backend directly:\n\n```\n# note: requires the gql_server_url environment variable to point to the server\n\nclass Pet(clearskies.Model):\n    def __init__(self, gql_backend, columns):\n        super().__init__(gql_backend, columns)\n\n    def columns_configuration(self):\n        return OrderedDict([\n            clearskies.column_types.string('name'),\n            clearskies.column_types.string('species'),\n        ])\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "clearskies bindings for Apollo GQL",
    "version": "0.1.2",
    "split_keywords": [
        "setuptools",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3da993ed2ed73fdf3cba8b84ad423bd50d9b5c4132e5ecf3bcc0417eb00b9129",
                "md5": "9dec67634e8c7ea5861cab983de48c23",
                "sha256": "7b26e5cf6bf785d9e2d14ba5f378256ae0303a662ebc3fd8159d656ba3e92aa3"
            },
            "downloads": -1,
            "filename": "clear_skies_gql-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9dec67634e8c7ea5861cab983de48c23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10537,
            "upload_time": "2023-01-24T12:21:01",
            "upload_time_iso_8601": "2023-01-24T12:21:01.443466Z",
            "url": "https://files.pythonhosted.org/packages/3d/a9/93ed2ed73fdf3cba8b84ad423bd50d9b5c4132e5ecf3bcc0417eb00b9129/clear_skies_gql-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c3a68a231e11e0c71eef535cb968be7cccfaeb96772f095231f8131976e74a0",
                "md5": "2a0e3206d8736fb0cf80c1d0d41146b7",
                "sha256": "442f70e878bda25ce17f58ced012705a012a9a6ed3ef8eee0d2a548824751483"
            },
            "downloads": -1,
            "filename": "clear-skies-gql-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2a0e3206d8736fb0cf80c1d0d41146b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9199,
            "upload_time": "2023-01-24T12:21:03",
            "upload_time_iso_8601": "2023-01-24T12:21:03.739467Z",
            "url": "https://files.pythonhosted.org/packages/7c/3a/68a231e11e0c71eef535cb968be7cccfaeb96772f095231f8131976e74a0/clear-skies-gql-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-24 12:21:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "cmancone",
    "github_project": "clearskies-gql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "clear-skies-gql"
}
        
Elapsed time: 0.03808s