graphql-http 2.1.4__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. graphql_http-2.2.0/PKG-INFO +134 -0
  2. graphql_http-2.2.0/README.md +106 -0
  3. graphql_http-2.2.0/VERSION +1 -0
  4. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/_index.md +46 -3
  5. graphql_http-2.2.0/example_advanced_server.py +128 -0
  6. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/graphiql/index.html +3334 -489
  7. graphql_http-2.2.0/graphql_http.egg-info/PKG-INFO +134 -0
  8. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http.egg-info/SOURCES.txt +1 -0
  9. graphql_http-2.2.0/test_server.py +1255 -0
  10. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_server.py +3 -0
  11. graphql_http-2.1.4/PKG-INFO +0 -316
  12. graphql_http-2.1.4/README.md +0 -288
  13. graphql_http-2.1.4/VERSION +0 -1
  14. graphql_http-2.1.4/graphql_http.egg-info/PKG-INFO +0 -316
  15. graphql_http-2.1.4/test_server.py +0 -41
  16. {graphql_http-2.1.4 → graphql_http-2.2.0}/.coverage +0 -0
  17. {graphql_http-2.1.4 → graphql_http-2.2.0}/.github/workflows/pages.yml +0 -0
  18. {graphql_http-2.1.4 → graphql_http-2.2.0}/.github/workflows/python-package.yml +0 -0
  19. {graphql_http-2.1.4 → graphql_http-2.2.0}/.gitignore +0 -0
  20. {graphql_http-2.1.4 → graphql_http-2.2.0}/.gitmodules +0 -0
  21. {graphql_http-2.1.4 → graphql_http-2.2.0}/LICENSE +0 -0
  22. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/.gitmodules +0 -0
  23. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/_index.md +0 -0
  24. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/api-reference.md +0 -0
  25. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/authentication.md +0 -0
  26. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/configuration.md +0 -0
  27. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/examples.md +0 -0
  28. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/getting-started.md +0 -0
  29. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/content/docs/testing.md +0 -0
  30. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/hugo.toml +0 -0
  31. {graphql_http-2.1.4 → graphql_http-2.2.0}/docs/index.md +0 -0
  32. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/README.md +0 -0
  33. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/__init__.py +0 -0
  34. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/advanced_server.py +0 -0
  35. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/auth_server.py +0 -0
  36. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/basic_server.py +0 -0
  37. {graphql_http-2.1.4 → graphql_http-2.2.0}/examples/graphql_api_server.py +0 -0
  38. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/__init__.py +0 -0
  39. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/error.py +0 -0
  40. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/helpers.py +0 -0
  41. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/introspection.py +0 -0
  42. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http/server.py +0 -0
  43. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http.egg-info/dependency_links.txt +0 -0
  44. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http.egg-info/requires.txt +0 -0
  45. {graphql_http-2.1.4 → graphql_http-2.2.0}/graphql_http.egg-info/top_level.txt +0 -0
  46. {graphql_http-2.1.4 → graphql_http-2.2.0}/pyproject.toml +0 -0
  47. {graphql_http-2.1.4 → graphql_http-2.2.0}/setup.cfg +0 -0
  48. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/__init__.py +0 -0
  49. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/app.py +0 -0
  50. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/app_federation.py +0 -0
  51. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/conftest.py +0 -0
  52. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_auth.py +0 -0
  53. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_cors.py +0 -0
  54. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_examples.py +0 -0
  55. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_federation.py +0 -0
  56. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_graphql_api.py +0 -0
  57. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_introspection.py +0 -0
  58. {graphql_http-2.1.4 → graphql_http-2.2.0}/tests/test_linting.py +0 -0
  59. {graphql_http-2.1.4 → graphql_http-2.2.0}/uv.lock +0 -0
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: graphql-http
3
+ Version: 2.2.0
4
+ Summary: HTTP Server for GraphQL.
5
+ Author-email: Robert Parker <rob@parob.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://gitlab.com/parob/graphql-http
8
+ Project-URL: Repository, https://gitlab.com/parob/graphql-http
9
+ Keywords: GraphQL,HTTP,Server,starlette
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: <3.13,>=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: graphql-core
19
+ Requires-Dist: graphql-api
20
+ Requires-Dist: packaging
21
+ Requires-Dist: graphql-schema-diff
22
+ Requires-Dist: pyjwt[crypto]
23
+ Requires-Dist: starlette
24
+ Requires-Dist: uvicorn
25
+ Requires-Dist: python-multipart
26
+ Requires-Dist: httpx
27
+ Dynamic: license-file
28
+
29
+ # GraphQL HTTP
30
+
31
+ [![PyPI version](https://badge.fury.io/py/graphql-http.svg)](https://badge.fury.io/py/graphql-http)
32
+ [![Python versions](https://img.shields.io/pypi/pyversions/graphql-http.svg)](https://pypi.org/project/graphql-http/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
+
35
+ **[📚 Documentation](https://graphql-http.parob.com/)** | **[📦 PyPI](https://pypi.org/project/graphql-http/)** | **[🔧 GitHub](https://github.com/parob/graphql-http)**
36
+
37
+ ---
38
+
39
+ A lightweight, production-ready HTTP server for GraphQL APIs built on top of Starlette/FastAPI. This server provides a simple yet powerful way to serve GraphQL schemas over HTTP with built-in support for authentication, CORS, GraphiQL integration, and more.
40
+
41
+ ## Features
42
+
43
+ - 🚀 **High Performance**: Built on Starlette/ASGI for excellent async performance
44
+ - 🔐 **JWT Authentication**: Built-in JWT authentication with JWKS support
45
+ - 🌐 **CORS Support**: Configurable CORS middleware for cross-origin requests
46
+ - 🎨 **GraphiQL Integration**: Interactive GraphQL IDE for development
47
+ - 📊 **Health Checks**: Built-in health check endpoints
48
+ - 🔄 **Batch Queries**: Support for batched GraphQL operations
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ uv add graphql_http
54
+ ```
55
+
56
+ Or with pip:
57
+ ```bash
58
+ pip install graphql_http
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ ### Basic Usage
64
+
65
+ ```python
66
+ from graphql import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString
67
+ from graphql_http import GraphQLHTTP
68
+
69
+ # Define your GraphQL schema
70
+ schema = GraphQLSchema(
71
+ query=GraphQLObjectType(
72
+ name="Query",
73
+ fields={
74
+ "hello": GraphQLField(
75
+ GraphQLString,
76
+ resolve=lambda obj, info: "Hello, World!"
77
+ )
78
+ }
79
+ )
80
+ )
81
+
82
+ # Create the HTTP server
83
+ app = GraphQLHTTP(schema=schema)
84
+
85
+ # Run the server
86
+ if __name__ == "__main__":
87
+ app.run(host="0.0.0.0", port=8000)
88
+ ```
89
+
90
+ ### Using with graphql-api
91
+
92
+ For building GraphQL schemas, use [graphql-api](https://graphql-api.parob.com/):
93
+
94
+ ```python
95
+ from graphql_api import GraphQLAPI
96
+ from graphql_http import GraphQLHTTP
97
+
98
+ api = GraphQLAPI()
99
+
100
+ @api.type(is_root_type=True)
101
+ class Query:
102
+ @api.field
103
+ def hello(self, name: str = "World") -> str:
104
+ return f"Hello, {name}!"
105
+
106
+ server = GraphQLHTTP.from_api(api)
107
+ server.run()
108
+ ```
109
+
110
+ ## Related Projects
111
+
112
+ - **[graphql-api](https://graphql-api.parob.com/)** - Build GraphQL schemas with decorators
113
+ - **[graphql-db](https://graphql-db.parob.com/)** - SQLAlchemy integration for database-backed APIs
114
+ - **[graphql-mcp](https://graphql-mcp.parob.com/)** - Expose GraphQL as MCP tools
115
+
116
+ See the [documentation](https://graphql-http.parob.com/) for configuration, authentication, and advanced features.
117
+
118
+
119
+ ## Documentation
120
+
121
+ **Visit the [official documentation](https://graphql-http.parob.com/)** for comprehensive guides, examples, and API reference.
122
+
123
+ ### Key Topics
124
+
125
+ - **[Getting Started](https://graphql-http.parob.com/docs/getting-started/)** - Quick introduction and basic usage
126
+ - **[Configuration](https://graphql-http.parob.com/docs/configuration/)** - Configure your HTTP server
127
+ - **[Authentication](https://graphql-http.parob.com/docs/authentication/)** - JWT and auth setup
128
+ - **[Testing](https://graphql-http.parob.com/docs/testing/)** - Test your GraphQL endpoints
129
+ - **[Examples](https://graphql-http.parob.com/docs/examples/)** - Real-world usage examples
130
+ - **[API Reference](https://graphql-http.parob.com/docs/api-reference/)** - Complete API documentation
131
+
132
+ ## License
133
+
134
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,106 @@
1
+ # GraphQL HTTP
2
+
3
+ [![PyPI version](https://badge.fury.io/py/graphql-http.svg)](https://badge.fury.io/py/graphql-http)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/graphql-http.svg)](https://pypi.org/project/graphql-http/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **[📚 Documentation](https://graphql-http.parob.com/)** | **[📦 PyPI](https://pypi.org/project/graphql-http/)** | **[🔧 GitHub](https://github.com/parob/graphql-http)**
8
+
9
+ ---
10
+
11
+ A lightweight, production-ready HTTP server for GraphQL APIs built on top of Starlette/FastAPI. This server provides a simple yet powerful way to serve GraphQL schemas over HTTP with built-in support for authentication, CORS, GraphiQL integration, and more.
12
+
13
+ ## Features
14
+
15
+ - 🚀 **High Performance**: Built on Starlette/ASGI for excellent async performance
16
+ - 🔐 **JWT Authentication**: Built-in JWT authentication with JWKS support
17
+ - 🌐 **CORS Support**: Configurable CORS middleware for cross-origin requests
18
+ - 🎨 **GraphiQL Integration**: Interactive GraphQL IDE for development
19
+ - 📊 **Health Checks**: Built-in health check endpoints
20
+ - 🔄 **Batch Queries**: Support for batched GraphQL operations
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ uv add graphql_http
26
+ ```
27
+
28
+ Or with pip:
29
+ ```bash
30
+ pip install graphql_http
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### Basic Usage
36
+
37
+ ```python
38
+ from graphql import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString
39
+ from graphql_http import GraphQLHTTP
40
+
41
+ # Define your GraphQL schema
42
+ schema = GraphQLSchema(
43
+ query=GraphQLObjectType(
44
+ name="Query",
45
+ fields={
46
+ "hello": GraphQLField(
47
+ GraphQLString,
48
+ resolve=lambda obj, info: "Hello, World!"
49
+ )
50
+ }
51
+ )
52
+ )
53
+
54
+ # Create the HTTP server
55
+ app = GraphQLHTTP(schema=schema)
56
+
57
+ # Run the server
58
+ if __name__ == "__main__":
59
+ app.run(host="0.0.0.0", port=8000)
60
+ ```
61
+
62
+ ### Using with graphql-api
63
+
64
+ For building GraphQL schemas, use [graphql-api](https://graphql-api.parob.com/):
65
+
66
+ ```python
67
+ from graphql_api import GraphQLAPI
68
+ from graphql_http import GraphQLHTTP
69
+
70
+ api = GraphQLAPI()
71
+
72
+ @api.type(is_root_type=True)
73
+ class Query:
74
+ @api.field
75
+ def hello(self, name: str = "World") -> str:
76
+ return f"Hello, {name}!"
77
+
78
+ server = GraphQLHTTP.from_api(api)
79
+ server.run()
80
+ ```
81
+
82
+ ## Related Projects
83
+
84
+ - **[graphql-api](https://graphql-api.parob.com/)** - Build GraphQL schemas with decorators
85
+ - **[graphql-db](https://graphql-db.parob.com/)** - SQLAlchemy integration for database-backed APIs
86
+ - **[graphql-mcp](https://graphql-mcp.parob.com/)** - Expose GraphQL as MCP tools
87
+
88
+ See the [documentation](https://graphql-http.parob.com/) for configuration, authentication, and advanced features.
89
+
90
+
91
+ ## Documentation
92
+
93
+ **Visit the [official documentation](https://graphql-http.parob.com/)** for comprehensive guides, examples, and API reference.
94
+
95
+ ### Key Topics
96
+
97
+ - **[Getting Started](https://graphql-http.parob.com/docs/getting-started/)** - Quick introduction and basic usage
98
+ - **[Configuration](https://graphql-http.parob.com/docs/configuration/)** - Configure your HTTP server
99
+ - **[Authentication](https://graphql-http.parob.com/docs/authentication/)** - JWT and auth setup
100
+ - **[Testing](https://graphql-http.parob.com/docs/testing/)** - Test your GraphQL endpoints
101
+ - **[Examples](https://graphql-http.parob.com/docs/examples/)** - Real-world usage examples
102
+ - **[API Reference](https://graphql-http.parob.com/docs/api-reference/)** - Complete API documentation
103
+
104
+ ## License
105
+
106
+ MIT License - see LICENSE file for details.
@@ -0,0 +1 @@
1
+ 2.2.0
@@ -63,9 +63,13 @@ if __name__ == "__main__":
63
63
 
64
64
  Visit [http://localhost:8000/graphql](http://localhost:8000/graphql) to access the GraphiQL interface.
65
65
 
66
- ## Integration with GraphQL-API
66
+ ## Related Projects
67
67
 
68
- For advanced schema definition with automatic type inference:
68
+ `graphql-http` provides HTTP serving for GraphQL APIs. For additional functionality:
69
+
70
+ ### Schema Building: graphql-api
71
+
72
+ Build GraphQL schemas with a decorator-based approach using [graphql-api](https://graphql-api.parob.com/):
69
73
 
70
74
  ```python
71
75
  from graphql_api import GraphQLAPI
@@ -79,11 +83,50 @@ class Query:
79
83
  def hello(self, name: str = "World") -> str:
80
84
  return f"Hello, {name}!"
81
85
 
82
- # Create server from API
86
+ # Create HTTP server from API
87
+ server = GraphQLHTTP.from_api(api)
88
+ server.run()
89
+ ```
90
+
91
+ **Learn more**: [graphql-api documentation](https://graphql-api.parob.com/)
92
+
93
+ ### Database Integration: graphql-db
94
+
95
+ For database-backed APIs, use [graphql-db](https://graphql-db.parob.com/) with graphql-http:
96
+
97
+ ```python
98
+ from graphql_api import GraphQLAPI
99
+ from graphql_http import GraphQLHTTP
100
+ from graphql_db.orm_base import DatabaseManager
101
+
102
+ db_manager = DatabaseManager(url="sqlite:///myapp.db")
103
+ api = GraphQLAPI()
104
+ # ... define your schema with database models ...
105
+
83
106
  server = GraphQLHTTP.from_api(api)
84
107
  server.run()
85
108
  ```
86
109
 
110
+ **Learn more**: [graphql-db documentation](https://graphql-db.parob.com/)
111
+
112
+ ### MCP Tools: graphql-mcp
113
+
114
+ Expose your GraphQL API as MCP tools alongside HTTP with [graphql-mcp](https://graphql-mcp.parob.com/):
115
+
116
+ ```python
117
+ from graphql_api import GraphQLAPI
118
+ from graphql_mcp.server import GraphQLMCP
119
+
120
+ api = GraphQLAPI()
121
+ # ... define your schema ...
122
+
123
+ # Serve both MCP and GraphQL HTTP
124
+ server = GraphQLMCP.from_api(api, graphql_http=True)
125
+ app = server.http_app()
126
+ ```
127
+
128
+ **Learn more**: [graphql-mcp documentation](https://graphql-mcp.parob.com/)
129
+
87
130
  ## What's Next?
88
131
 
89
132
  - 📚 **[Getting Started](docs/getting-started/)** - Learn the basics with our comprehensive guide
@@ -0,0 +1,128 @@
1
+ import enum
2
+ import os
3
+ from dataclasses import dataclass
4
+
5
+ from typing import List
6
+
7
+ from context_helper import ctx, Context
8
+ from graphql_api import GraphQLAPI, field
9
+
10
+ from typing import Optional
11
+
12
+ from sqlalchemy import create_engine
13
+ from sqlalchemy_gql import GraphQLSQLAlchemyMixin
14
+ from sqlmodel import Field, SQLModel, Session, select, col
15
+
16
+ from graphql_http_server import GraphQLHTTPServer
17
+
18
+
19
+ class Note(GraphQLSQLAlchemyMixin, SQLModel, table=True):
20
+ id: int = Field(primary_key=True)
21
+ title: str = ""
22
+ note: str = ""
23
+
24
+ @field(mutable=True)
25
+ def update(self, title: str = None, note: str = None) -> 'Note':
26
+ if title is not None:
27
+ self.title = title
28
+
29
+ if note is not None:
30
+ self.note = note
31
+
32
+ return self
33
+
34
+ @field(mutable=True)
35
+ def delete(self) -> bool:
36
+ ctx.session.delete(self)
37
+ return True
38
+
39
+
40
+ class OrderByDirection(enum.Enum):
41
+ asc = "asc"
42
+ desc = "desc"
43
+
44
+ @dataclass
45
+ class OrderBy:
46
+ key: str
47
+ direction: OrderByDirection = OrderByDirection.asc
48
+
49
+ @dataclass
50
+ class NoteFilter:
51
+ ids: List[int] = None
52
+ title: str = ""
53
+
54
+ class Notes:
55
+
56
+ @field(mutable=True)
57
+ def create_note(self, title: str, note: str) -> Note:
58
+ note = Note(title=title, note=note)
59
+ ctx.session.add(note)
60
+
61
+ return note
62
+
63
+ @field
64
+ def all_notes(
65
+ self,
66
+ order_by: List[OrderBy] = None,
67
+ filter: NoteFilter = None,
68
+ limit: int = 50,
69
+ offset: int = 0
70
+ ) -> List[Note]:
71
+ """
72
+ Find `Notes`
73
+ """
74
+ query = select(Note)
75
+
76
+ if filter and filter.ids:
77
+ query = query.where(col(Note.id).in_(filter.ids))
78
+
79
+ if filter and filter.title:
80
+ query = query.where(col(Note.title).contains(filter.title))
81
+
82
+ if order_by:
83
+ for _order_by in order_by:
84
+ c = getattr(Note,_order_by.key)
85
+ if _order_by.direction == OrderByDirection.asc:
86
+ c = c.asc()
87
+ else:
88
+ c = c.desc()
89
+ query = query.order_by(c)
90
+
91
+ return ctx.session.exec(query.limit(limit).offset(offset)).all()
92
+
93
+ @field
94
+ def note(self, id: int = None, title: str = None) -> Optional[Note]:
95
+ """
96
+ Title or id must be an exact match.
97
+ """
98
+ if id:
99
+ return ctx.session.exec(select(Note).where(Note.id==id)).one()
100
+ if title:
101
+ return ctx.session.exec(select(Note).where(Note.title==title)).one()
102
+
103
+
104
+ path = os.path.join(os.path.dirname(__file__), './example.graphql')
105
+ with open(path, mode='r') as file:
106
+ default_query = file.read()
107
+
108
+ engine = create_engine("sqlite://")
109
+
110
+ SQLModel.metadata.create_all(engine)
111
+
112
+ server = GraphQLHTTPServer.from_api(
113
+ api=GraphQLAPI(root_type=Notes),
114
+ graphiql_default_query=default_query
115
+ )
116
+
117
+
118
+ def main(request):
119
+ with Session(engine) as session:
120
+ with Context(session=session):
121
+ response = server.dispatch(request=request)
122
+ session.commit()
123
+
124
+ return response
125
+
126
+
127
+ if __name__ == "__main__":
128
+ server.run(main=main, port=3500)