Skip to content

Commit 4ab024e

Browse files
authored
Feat: Added support up to federation v2.11 (#30)
* chore: update docker syntaxes * chore: add support for python3.13, bump graphene-directives * feat: add support upto federation v2.11 Added decorators `@context`,`fromContext`, `@cost`, `@listSize` * fix: ci, bump to python 11 * refact: federation schema file typo * feat: add support for python 3.14 Bumped graphene-directives to 0.5.0 Dropped support up to python 3.8
1 parent 8fd42e3 commit 4ab024e

File tree

91 files changed

+1282
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1282
-175
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python 3.10
15-
uses: actions/setup-python@v3
13+
- uses: actions/checkout@v5
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
1616
with:
17-
python-version: '3.10'
17+
python-version: '3.14'
1818
- name: Build wheel and source tarball
1919
run: |
20-
pip install wheel
21-
python setup.py sdist bdist_wheel
20+
python -m pip install --upgrade pip
21+
pip install build
22+
python -m build
2223
- name: Publish a Python distribution to PyPI
23-
uses: pypa/gh-action-pypi-publish@v1.1.0
24+
uses: pypa/gh-action-pypi-publish@v1.8.14
2425
with:
2526
user: __token__
2627
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v1
10+
- uses: actions/checkout@v4
1111
- name: Build environment
1212
run: make integration-build
1313
- name: Run Integration Tests

.github/workflows/lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
11-
- name: Set up Python 3.10
12-
uses: actions/setup-python@v4
10+
- uses: actions/checkout@v4
11+
- name: Set up Python
12+
uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.10.5
14+
python-version: 3.14
1515
- name: Install dependencies
1616
run: |
1717
python -m pip install --upgrade pip

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
strategy:
99
max-parallel: 4
1010
matrix:
11-
python-version: ["3.9", "3.10", "3.11", "3.12"]
11+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1212

1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v1
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-alpine
1+
FROM python:3-alpine
22

33
# Disable Python buffering in order to see the logs immediatly
44
ENV PYTHONUNBUFFERED=1

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
# -------------------------
44

55
integration-build: ## Build environment for integration tests
6-
cd integration_tests && docker-compose build
6+
cd integration_tests && docker compose build
77
.PHONY: integration-build
88

99
integration-tests: ## Run integration tests
10-
cd integration_tests && docker-compose down && docker-compose run --rm tests
10+
cd integration_tests && docker compose down && docker compose run --rm tests
1111
.PHONY: integration-test
1212

1313
# -------------------------
1414
# Development and unit testing
1515
# -------------------------
1616

1717
dev-setup: ## Install development dependencies
18-
docker-compose up --build -d
18+
docker compose up --build -d
1919
.PHONY: dev-setup
2020

2121
tests: ## Run unit tests
22-
docker-compose run graphene_federation py.test tests --cov=graphene_federation -vv
22+
docker compose run --rm --remove-orphans graphene_federation py.test tests --cov=graphene_federation -vv
2323
.PHONY: tests
2424

2525
check-style: ## Run linting
26-
docker-compose run graphene_federation black graphene_federation --check
26+
docker compose run --rm graphene_federation black graphene_federation --check
2727
.PHONY: check-style
2828

2929
check-types: ## Run typing check
30-
docker-compose run graphene_federation mypy graphene_federation
30+
docker compose run --rm graphene_federation mypy graphene_federation
3131
.PHONY: check-types
3232

3333
# -------------------------

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ If you need to use a version compatible with `graphene` v2 I recommend using the
3838
- [x] v2.3
3939
- [x] v2.4
4040
- [x] v2.5
41-
- [x] v2.6 `STABLE_VERSION` . Rover dev supports only upto v2.6
42-
- [x] v2.7 `LATEST_VERSION`
41+
- [x] v2.6
42+
- [x] v2.7
43+
- [x] v2.8
44+
- [x] v2.9
45+
- [x] v2.10
46+
- [x] v2.11 `STABLE_VERSION`,`LATEST_VERSION`
4347

4448
All directives could be easily integrated with the help of [graphene-directives](https://github.com/strollby/graphene-directives).
4549
Now every directive's values are validated at run time itself by [graphene-directives](https://github.com/strollby/graphene-directives).
4650

47-
### Directives (v2.7)
51+
### Directives (v2.11)
4852

4953
```graphql
5054
directive @composeDirective(name: String!) repeatable on SCHEMA
@@ -84,21 +88,38 @@ directive @authenticated on
8488
| INTERFACE
8589
| SCALAR
8690
| ENUM
87-
directive @requiresScopes(scopes: [[federation__Scope!]!]!) on
91+
directive @requiresScopes(scopes: [[Scope!]!]!) on
8892
FIELD_DEFINITION
8993
| OBJECT
9094
| INTERFACE
9195
| SCALAR
9296
| ENUM
93-
directive @policy(policies: [[federation__Policy!]!]!) on
97+
directive @policy(policies: [[Policy!]!]!) on
9498
| FIELD_DEFINITION
9599
| OBJECT
96100
| INTERFACE
97101
| SCALAR
98102
| ENUM
103+
directive @context(name: String!) on OBJECT | INTERFACE | UNION
104+
directive @fromContext(field: ContextFieldValue) on ARGUMENT_DEFINITION
105+
directive @listSize(
106+
assumedSize: Int
107+
slicingArguments: [String!]
108+
sizedFields: [String!]
109+
requireOneSlicingArgument: Boolean = true
110+
) on FIELD_DEFINITION
111+
directive @cost(weight: Int!) on
112+
ARGUMENT_DEFINITION
113+
| ENUM
114+
| FIELD_DEFINITION
115+
| INPUT_FIELD_DEFINITION
116+
| OBJECT
117+
| SCALAR
118+
| ENUM
99119
scalar federation__Policy
100120
scalar federation__Scope
101121
scalar FieldSet
122+
scalar federation__ContextFieldValue
102123
```
103124

104125
Read about directives in [official documentation](https://www.apollographql.com/docs/federation/federated-types/federated-directives)
@@ -430,10 +451,6 @@ schema = build_schema(query=Query, federation_version=LATEST_VERSION) # auto_cam
430451

431452
------------------------
432453

433-
## Known Issues
434-
435-
- Using `@composeDirective` with `@link` in Federation `v2.6` shows error in rover, rover cli only supports upto `v2.5` as of 16/01/2024
436-
437454
## Contributing
438455

439456
* You can run the unit tests by doing: `make tests`.

docker-compose.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
version: '3.5'
2-
31
services:
4-
52
graphene_federation:
63
container_name: graphene_federation
74
build:
85
context: .
96
volumes:
10-
- ./:/workdir
7+
- ./:/workdir
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
directive @composeDirective(name: String!) repeatable on SCHEMA
2+
directive @extends on OBJECT | INTERFACE
3+
directive @external on OBJECT | FIELD_DEFINITION
4+
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
5+
directive @inaccessible on
6+
| FIELD_DEFINITION
7+
| OBJECT
8+
| INTERFACE
9+
| UNION
10+
| ENUM
11+
| ENUM_VALUE
12+
| SCALAR
13+
| INPUT_OBJECT
14+
| INPUT_FIELD_DEFINITION
15+
| ARGUMENT_DEFINITION
16+
directive @interfaceObject on OBJECT
17+
directive @override(from: String!, label: String) on FIELD_DEFINITION
18+
directive @provides(fields: FieldSet!) on FIELD_DEFINITION
19+
directive @requires(fields: FieldSet!) on FIELD_DEFINITION
20+
directive @shareable repeatable on FIELD_DEFINITION | OBJECT
21+
directive @tag(name: String!) repeatable on
22+
| FIELD_DEFINITION
23+
| INTERFACE
24+
| OBJECT
25+
| UNION
26+
| ARGUMENT_DEFINITION
27+
| SCALAR
28+
| ENUM
29+
| ENUM_VALUE
30+
| INPUT_OBJECT
31+
| INPUT_FIELD_DEFINITION
32+
directive @authenticated on
33+
FIELD_DEFINITION
34+
| OBJECT
35+
| INTERFACE
36+
| SCALAR
37+
| ENUM
38+
directive @requiresScopes(scopes: [[federation__Scope!]!]!) on
39+
FIELD_DEFINITION
40+
| OBJECT
41+
| INTERFACE
42+
| SCALAR
43+
| ENUM
44+
directive @policy(policies: [[federation__Policy!]!]!) on
45+
| FIELD_DEFINITION
46+
| OBJECT
47+
| INTERFACE
48+
| SCALAR
49+
| ENUM
50+
directive @context(name: String!) on OBJECT | INTERFACE | UNION
51+
directive @fromContext(field: federation__ContextFieldValue) on ARGUMENT_DEFINITION
52+
directive @listSize(
53+
assumedSize: Int
54+
slicingArguments: [String!]
55+
sizedFields: [String!]
56+
requireOneSlicingArgument: Boolean = true
57+
) on FIELD_DEFINITION
58+
directive @cost(weight: Int!) on
59+
ARGUMENT_DEFINITION
60+
| ENUM
61+
| FIELD_DEFINITION
62+
| INPUT_FIELD_DEFINITION
63+
| OBJECT
64+
| SCALAR
65+
| ENUM
66+
scalar federation__Policy
67+
scalar federation__Scope
68+
scalar FieldSet
69+
scalar federation__ContextFieldValue
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
directive @composeDirective(name: String!) repeatable on SCHEMA
2+
directive @extends on OBJECT | INTERFACE
3+
directive @external on OBJECT | FIELD_DEFINITION
4+
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
5+
directive @inaccessible on
6+
| FIELD_DEFINITION
7+
| OBJECT
8+
| INTERFACE
9+
| UNION
10+
| ENUM
11+
| ENUM_VALUE
12+
| SCALAR
13+
| INPUT_OBJECT
14+
| INPUT_FIELD_DEFINITION
15+
| ARGUMENT_DEFINITION
16+
directive @interfaceObject on OBJECT
17+
directive @override(from: String!, label: String) on FIELD_DEFINITION
18+
directive @provides(fields: FieldSet!) on FIELD_DEFINITION
19+
directive @requires(fields: FieldSet!) on FIELD_DEFINITION
20+
directive @shareable repeatable on FIELD_DEFINITION | OBJECT
21+
directive @tag(name: String!) repeatable on
22+
| FIELD_DEFINITION
23+
| INTERFACE
24+
| OBJECT
25+
| UNION
26+
| ARGUMENT_DEFINITION
27+
| SCALAR
28+
| ENUM
29+
| ENUM_VALUE
30+
| INPUT_OBJECT
31+
| INPUT_FIELD_DEFINITION
32+
directive @authenticated on
33+
FIELD_DEFINITION
34+
| OBJECT
35+
| INTERFACE
36+
| SCALAR
37+
| ENUM
38+
directive @requiresScopes(scopes: [[federation__Scope!]!]!) on
39+
FIELD_DEFINITION
40+
| OBJECT
41+
| INTERFACE
42+
| SCALAR
43+
| ENUM
44+
directive @policy(policies: [[federation__Policy!]!]!) on
45+
| FIELD_DEFINITION
46+
| OBJECT
47+
| INTERFACE
48+
| SCALAR
49+
| ENUM
50+
directive @context(name: String!) on OBJECT | INTERFACE | UNION
51+
directive @fromContext(field: federation__ContextFieldValue) on ARGUMENT_DEFINITION
52+
directive @listSize(
53+
assumedSize: Int
54+
slicingArguments: [String!]
55+
sizedFields: [String!]
56+
requireOneSlicingArgument: Boolean = true
57+
) on FIELD_DEFINITION
58+
directive @cost(weight: Int!) on
59+
ARGUMENT_DEFINITION
60+
| ENUM
61+
| FIELD_DEFINITION
62+
| INPUT_FIELD_DEFINITION
63+
| OBJECT
64+
| SCALAR
65+
| ENUM
66+
scalar federation__Policy
67+
scalar federation__Scope
68+
scalar FieldSet
69+
scalar federation__ContextFieldValue

0 commit comments

Comments
 (0)