Skip to content

Commit

Permalink
Merge pull request #45 from DoctorJohn/graphene-v3
Browse files Browse the repository at this point in the history
Upgrade to graphene v3
  • Loading branch information
necaris authored Nov 9, 2020
2 parents a8acf13 + 51f3f13 commit a744fce
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 156 deletions.
51 changes: 23 additions & 28 deletions examples/departments.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,32 @@ def resolve_list_departments(self, info):


if __name__ == "__main__":
from graphql.execution.executors.sync import SyncExecutor

schema = graphene.Schema(query=Query)
result = schema.execute(
"""
query {
listDepartments {
id,
name,
employees {
...on Employee {
id
name
hiredOn
salary { rating }
}
...on Manager {
name
salary {
rating
amount
}
teamSize
query = """
query {
listDepartments {
id,
name,
employees {
...on Employee {
id
name
hiredOn
salary { rating }
}
...on Manager {
name
salary {
rating
amount
}
teamSize
}
}
}
}
}
""",
executor=SyncExecutor(),
return_promise=False,
)
}
"""
result = schema.execute(query)

print(result.errors)
print(json.dumps(result.data, indent=2))
4 changes: 2 additions & 2 deletions graphene_pydantic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def convert_pydantic_input_field(
"""
declared_type = getattr(field, "type_", None)
field_kwargs.setdefault(
"type",
"type_",
convert_pydantic_type(
declared_type, field, registry, parent_type=parent_type, model=model
),
Expand Down Expand Up @@ -126,7 +126,7 @@ def convert_pydantic_field(
"""
declared_type = getattr(field, "type_", None)
field_kwargs.setdefault(
"type",
"type_",
convert_pydantic_type(
declared_type, field, registry, parent_type=parent_type, model=model
),
Expand Down
96 changes: 30 additions & 66 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "graphene_pydantic"
version = "0.1.0"
version = "0.2.0"
description = "Graphene Pydantic integration"
readme = "README.md"
repository = "https://github.com/upsidetravel/graphene-pydantic"
Expand All @@ -21,7 +21,7 @@ keywords = ["api", "graphql", "protocol", "rest", "relay", "graphene", "pydantic
[tool.poetry.dependencies]
python = "^3.6"
# To keep things simple, we only support newer versions of Graphene & Pydantic
graphene = ">=2.1.3,<3"
graphene = ">=3.0b5"
pydantic = ">=1.0,<1.7"

[tool.poetry.dev-dependencies]
Expand Down
43 changes: 19 additions & 24 deletions tests/test_forward_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,29 @@ def resolve_list_foos(self, info):


def test_query():
from graphql.execution.executors.sync import SyncExecutor

schema = graphene.Schema(query=Query)
result = schema.execute(
"""
query {
listFoos {
id
name
bar {
id
name
foo {
id
baz {
query = """
query {
listFoos {
id
name
bar { id }
}
bar {
id
name
foo {
id
baz {
name
bar { id }
}
}
}
baz { name }
someBars { id }
}
}
baz { name }
someBars { id }
}
}
""",
executor=SyncExecutor(),
return_promise=False,
)
"""
result = schema.execute(query)

assert result.errors is None
assert result.data is not None
Expand Down
Loading

0 comments on commit a744fce

Please sign in to comment.