about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/strawberry-graphql/default.nix
blob: 40ae06c91c8fc31a80a50947673821365937e589 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
{ lib
, aiohttp
, asgiref
, buildPythonPackage
, chalice
, channels
, click
, daphne
, django
, email-validator
, fastapi
, fetchFromGitHub
, fetchpatch
, flask
, freezegun
, graphql-core
, libcst
, opentelemetry-api
, opentelemetry-sdk
, poetry-core
, pydantic
, pygments
, pyinstrument
, pytest-aiohttp
, pytest-asyncio
, pytest-django
, pytest-emoji
, pytest-flask
, pytest-mock
, pytest-snapshot
, pytestCheckHook
, python-dateutil
, python-multipart
, pythonOlder
, rich
, sanic
, sanic-testing
, starlette
, typing-extensions
, uvicorn
}:

buildPythonPackage rec {
  pname = "strawberry-graphql";
  version = "0.219.2";
  format = "pyproject";

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "strawberry-graphql";
    repo = "strawberry";
    rev = "refs/tags/${version}";
    hash = "sha256-uIUETjzuDnlQp6wM7uxyLRSMT5uyrXFrI9NilcjP0BU=";
  };

  patches = [
    (fetchpatch {
      # https://github.com/strawberry-graphql/strawberry/pull/2199
      name = "switch-to-poetry-core.patch";
      url = "https://github.com/strawberry-graphql/strawberry/commit/710bb96f47c244e78fc54c921802bcdb48f5f421.patch";
      hash = "sha256-ekUZ2hDPCqwXp9n0YjBikwSkhCmVKUzQk7LrPECcD7Y=";
    })
    (fetchpatch {
      # https://github.com/strawberry-graphql/strawberry/pull/3255
      name = "fix-tests-with-pydantic_2.patch";
      url = "https://github.com/strawberry-graphql/strawberry/commit/0a0dc284ee6d31d4e82ac7ff1ed9fea4dff39fa6.patch";
      hash = "sha256-LACWD7XA6YL/apJwhpx3LPCKxKUfa+XWyTLK+Zkxlaw=";
    })
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace "--emoji --mypy-ini-file=mypy.ini" "" \
  '';

  nativeBuildInputs = [
    poetry-core
  ];

  propagatedBuildInputs = [
    graphql-core
    python-dateutil
    typing-extensions
  ];

  passthru.optional-dependencies = {
    aiohttp = [
      aiohttp
      pytest-aiohttp
    ];
    asgi = [
      starlette
      python-multipart
    ];
    debug = [
      rich
      libcst
    ];
    debug-server = [
      click
      libcst
      pygments
      python-multipart
      rich
      starlette
      uvicorn
    ];
    django = [
      django
      pytest-django
      asgiref
    ];
    channels = [
      channels
      asgiref
    ];
    flask = [
      flask
      pytest-flask
    ];
    opentelemetry = [
      opentelemetry-api
      opentelemetry-sdk
    ];
    pydantic = [
      pydantic
    ];
    sanic = [
      sanic
    ];
    fastapi = [
      fastapi
      python-multipart
    ];
    chalice = [
      chalice
    ];
    cli = [
      click
      pygments
      rich
      libcst
    ];
    # starlite = [
    #   starlite
    # ];
    pyinstrument = [
      pyinstrument
    ];
  };

  nativeCheckInputs = [
    daphne
    email-validator
    freezegun
    pytest-asyncio
    pytest-emoji
    pytest-mock
    pytest-snapshot
    pytestCheckHook
    sanic-testing
  ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);

  pythonImportsCheck = [
    "strawberry"
  ];

  disabledTestPaths = [
    "tests/benchmarks/"
    "tests/cli/"
    "tests/django/test_dataloaders.py"
    "tests/exceptions/"
    "tests/http/"
    "tests/mypy/test_plugin.py" # avoid dependency on mypy
    "tests/schema/extensions/"
    "tests/schema/test_dataloaders.py"
    "tests/schema/test_lazy/"
    "tests/starlite/"
    "tests/test_dataloaders.py"
    "tests/utils/test_pretty_print.py"
    "tests/websockets/test_graphql_transport_ws.py"
  ];

  __darwinAllowLocalNetworking = true;

  meta = with lib; {
    description = "A GraphQL library for Python that leverages type annotations";
    mainProgram = "strawberry";
    homepage = "https://strawberry.rocks";
    changelog = "https://github.com/strawberry-graphql/strawberry/blob/${version}/CHANGELOG.md";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ izorkin ];
  };
}