Skip to content

Commit 600ef65

Browse files
author
Hadrien
committed
Support React v16 and fetch v3
Current code is stuck to react v15 and fetch v2 due to how those packages are made available on unpkg: URLs are not the same. This commit allows to use react v16 and fetch v3 by inspecting required version to include the proper URL.
1 parent ab18c41 commit 600ef65

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Resources/views/GraphiQL/index.html.twig

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@
1313
</style>
1414
<link href="https://unpkg.com/graphiql@{{ versions.graphiql }}/graphiql.css" rel="stylesheet">
1515
{% endblock style %}
16-
<script src="https://unpkg.com/whatwg-fetch@{{ versions.fetch }}/fetch.js"></script>
17-
<script src="https://unpkg.com/react@{{ versions.react }}/dist/react.min.js"></script>
18-
<script src="https://unpkg.com/react-dom@{{ versions.react }}/dist/react-dom.min.js"></script>
16+
{% if versions.fetch matches '/^[~^]?2/' %}
17+
<script src="https://unpkg.com/whatwg-fetch@{{ versions.fetch }}/fetch.js"></script>
18+
{% else %}
19+
<script src="https://unpkg.com/whatwg-fetch@{{ versions.fetch }}/dist/fetch.umd.js"></script>
20+
{% endif %}
21+
{% if versions.react matches '/^[~^]?15/' %}
22+
<script src="https://unpkg.com/react@{{ versions.react }}/dist/react.min.js"></script>
23+
<script src="https://unpkg.com/react-dom@{{ versions.react }}/dist/react-dom.min.js"></script>
24+
{% else %}
25+
<script src="https://unpkg.com/react@{{ versions.react }}/umd/react.production.min.js"></script>
26+
<script src="https://unpkg.com/react-dom@{{ versions.react }}/umd/react-dom.production.min.js"></script>
27+
{% endif %}
1928
<script src="https://unpkg.com/graphiql@{{ versions.graphiql }}/graphiql.min.js"></script>
2029
<title>{% block title %}GraphiQL{% endblock title %}</title>
2130
{% endblock head %}

0 commit comments

Comments
 (0)