{"id":15192270,"url":"https://github.com/mononobi/grafliq","last_synced_at":"2026-02-13T20:03:37.019Z","repository":{"id":236165449,"uuid":"792054031","full_name":"mononobi/grafliq","owner":"mononobi","description":"A simple and pythonic way to query GraphQL endpoints without having to do any string manipulation.","archived":false,"fork":false,"pushed_at":"2025-02-08T17:37:23.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-08T10:52:59.049Z","etag":null,"topics":["graphql","graphql-client","graphql-queries","graphql-query","graphql-query-builder","graphql-query-generator","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mononobi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-25T22:16:44.000Z","updated_at":"2025-02-08T17:37:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"825633b9-9aa7-4c34-afe7-775061046455","html_url":"https://github.com/mononobi/grafliq","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"e3a078b3f50837b0dafd9911a9d30605ffb93da6"},"previous_names":["mononobi/grafliq"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mononobi/grafliq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mononobi%2Fgrafliq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mononobi%2Fgrafliq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mononobi%2Fgrafliq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mononobi%2Fgrafliq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mononobi","download_url":"https://codeload.github.com/mononobi/grafliq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mononobi%2Fgrafliq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260789717,"owners_count":23063620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-client","graphql-queries","graphql-query","graphql-query-builder","graphql-query-generator","python","python3"],"created_at":"2024-09-27T21:21:02.323Z","updated_at":"2026-02-13T20:03:32.001Z","avatar_url":"https://github.com/mononobi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grafliq\r\nA simple and pythonic way to query GraphQL endpoints without having to do \r\nany string manipulation.\r\n\r\nGrafliq is a GraphQL client that provides a convenient way to handle GraphQL queries. \r\nInstead of building your query by manipulating and concatenating strings, you build \r\nyour queries using function calls, eliminating all the complications and problems \r\nassociated with string manipulation, and making maintenance an easy task.\r\n\r\nAnother big advantage of Grafliq is that it does not require you to replicate the entire GraphQL server schema on your client. \r\nThat would make your client wrongly aware of your server and add another layer of time-consuming maintenance to your code. \r\nThe client is only aware of the query and will only need to change the query if the server query structure changes.\r\n\r\n## Important note\r\nGrafliq only supports the `query` operation of GraphQL, there is no support \r\nfor `mutations` and `subscriptions` and there will be none in the foreseeable future.\r\n\r\n## Installing\r\n\r\n**Install using pip**:\r\n\r\n**`pip install grafliq`**\r\n\r\n## Example using function calls as GraphQL operations (recommended)\r\n\r\nLet's say we want to have a GraphQL query with the following structure:\r\n\r\n```\r\n{\r\n  category(name: \"household-appliances\") {\r\n    electronics {\r\n      gaming_consoles(\r\n        fromReleaseDate: \"2000-01-01\"\r\n        fromPrice: \"150\"\r\n        discontinued: false\r\n        colors: [BLACK, WHITE, RED]\r\n      ) {\r\n        brand\r\n        name\r\n        color\r\n        discontinued\r\n        release_date\r\n        price(currency: \"euro\")\r\n        model {\r\n          name\r\n          version\r\n        }\r\n        customer_rating(fromRatingDate: \"2002-10-01\") {\r\n          count\r\n          rates {\r\n            average(decimalCount: 2)\r\n            highest\r\n            lowest\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nWe can generate the above query using the following Python code:\r\n\r\n```python\r\nfrom datetime import date\r\nfrom grafliq.builder import GraphQL\r\nfrom grafliq.query import NestedField, Quote, NoQuote, CustomizableField\r\n\r\nquery = GraphQL(\r\n    endpoint='http://127.0.0.1:8080/graphql-api'\r\n).category(\r\n    name='household-appliances'\r\n).electronics(\r\n).gaming_consoles(\r\n    'brand', 'name', 'color', 'discontinued', 'release_date',\r\n    CustomizableField('price', currency=\"euro\"),\r\n    NestedField('model',\r\n                'name', 'version'),\r\n    NestedField('customer_rating',\r\n                'count',\r\n                NestedField('rates',\r\n                            CustomizableField('average', decimalCount=2),\r\n                            'highest', 'lowest'),\r\n                fromRatingDate=date(2002, 10, 1)),\r\n    fromReleaseDate=date(2000, 1, 1),\r\n    fromPrice=Quote(150),\r\n    discontinued=False,\r\n    colors=NoQuote(['BLACK', 'WHITE', 'RED'])\r\n)\r\n\r\n\"\"\"\r\nTo get the query as a string, you can either do this:\r\n\"\"\"\r\n\r\nquery_string1 = str(query)\r\n\r\n\"\"\"\r\nOr you can call `.generate()` on the query object:\r\n\"\"\"\r\n\r\nquery_string2 = query.generate()\r\n\r\n\"\"\"\r\nIf you pass the `endpoint` to the `GraphQL` initializer, you can \r\ncall `.execute()` directly on the query object to call the remote API and get the result:\r\n\"\"\"\r\n\r\nresult = query.execute()\r\n\r\n\"\"\"\r\nNote that if you have not passed the `endpoint` to the \r\n`GraphQL` initializer, by calling the `.execute()` function, an error will be raised.\r\n\"\"\"\r\n```\r\n\r\nAs shown in the example above, any operation available in the remote GraphQL API \r\nwill be available as a function on the `GraphQL` object.\r\n\r\n## Example using generic query\r\n\r\nIf you want to dynamically generate GraphQL queries \r\n(.ex in an automated script, from user input, ...), you can do this with \r\nthe following example, which will generate exactly the same GraphQL query:\r\n\r\n```python\r\nfrom datetime import date\r\nfrom grafliq.builder import GraphQL\r\nfrom grafliq.query import NestedField, Quote, NoQuote, CustomizableField\r\n\r\nquery = GraphQL(\r\n    endpoint='http://127.0.0.1:8080/graphql-api'\r\n).query(\r\n    'category',\r\n    name='household-appliances'\r\n).query(\r\n    'electronics'\r\n).query(\r\n    'gaming_consoles',\r\n    'brand', 'name', 'color', 'discontinued', 'release_date',\r\n    CustomizableField('price', currency=\"euro\"),\r\n    NestedField('model',\r\n                'name', 'version'),\r\n    NestedField('customer_rating',\r\n                'count',\r\n                NestedField('rates',\r\n                            CustomizableField('average', decimalCount=2),\r\n                            'highest', 'lowest'),\r\n                fromRatingDate=date(2002, 10, 1)),\r\n    fromReleaseDate=date(2000, 1, 1),\r\n    fromPrice=Quote(150),\r\n    discontinued=False,\r\n    colors=NoQuote(['BLACK', 'WHITE', 'RED'])\r\n)\r\n```\r\n\r\n## Contribute to Grafliq development\r\n\r\nI appreciate any kind of contribution to the development of Grafliq, \r\nespecially to add support for mutations and subscriptions.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmononobi%2Fgrafliq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmononobi%2Fgrafliq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmononobi%2Fgrafliq/lists"}