Skip to content

Commit 7fa9ca5

Browse files
authored
fix: do not use api_graphql_graphiql route when graphiQl is disabled because it won’t exist (api-platform#5266)
1 parent d0fcd70 commit 7fa9ca5

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/Symfony/Bundle/Resources/public/init-all-ui.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
const graphiQlLink = document.querySelector('.graphiql-link');
4+
if (graphiQlLink) {
5+
graphiQlLink.addEventListener('click', e => {
6+
if (!e.target.hasAttribute('href')) {
7+
alert('GraphQL support is not enabled, see https://api-platform.com/docs/core/graphql/');
8+
}
9+
});
10+
}

src/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
{% set active_ui = app.request.get('ui', 'swagger_ui') %}
8585
{% if swaggerUiEnabled and active_ui != 'swagger_ui' %}<a href="{{ path('api_doc') }}">Swagger UI</a>{% endif %}
8686
{% if reDocEnabled and active_ui != 're_doc' %}<a href="{{ path('api_doc', {'ui': 're_doc'}) }}">ReDoc</a>{% endif %}
87-
<a href="{{ path('api_graphql_graphiql') }}" class="graphql-docs-link" {{ graphiQlEnabled ? 'data-graphql-enabled' }}>GraphiQL</a>
87+
{% if not graphQlEnabled or graphiQlEnabled %}<a {% if graphiQlEnabled %}href="{{ path('api_graphql_graphiql') }}"{% endif %} class="graphiql-link">GraphiQL</a>{% endif %}
8888
{% if graphQlPlaygroundEnabled %}<a href="{{ path('api_graphql_graphql_playground') }}">GraphQL Playground</a>{% endif %}
8989
</div>
9090
</div>
@@ -99,7 +99,7 @@
9999
<script src="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui-standalone-preset.js', assetPackage) }}"></script>
100100
<script src="{{ asset('bundles/apiplatform/init-swagger-ui.js', assetPackage) }}"></script>
101101
{% endif %}
102-
<script src="{{ asset('bundles/apiplatform/init-all-ui.js', assetPackage) }}"></script>
102+
<script src="{{ asset('bundles/apiplatform/init-common-ui.js', assetPackage) }}" defer></script>
103103
{% endblock %}
104104

105105
</body>

0 commit comments

Comments
 (0)