Skip to content

Add option to configure CDN serving GraphiQL files #3826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 3 tasks
parth-paradkar opened this issue Mar 31, 2025 · 6 comments
Closed
1 of 3 tasks

Add option to configure CDN serving GraphiQL files #3826

parth-paradkar opened this issue Mar 31, 2025 · 6 comments

Comments

@parth-paradkar
Copy link

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

Can we add an option to override the default unkpg.com CDN serving the GraphiQL IDE? (given the recent issues)-

graphql/graphiql#3877
unpkg/unpkg#412
unpkg/unpkg#443

Users may want to use another CDN in such incidents.

@patrick91
Copy link
Member

@parth-paradkar it's not too difficult to update the GraphiQL template already, no?

I fear that adding another config would make the template more complex for not much gain 😊

@parth-paradkar
Copy link
Author

I see, no worries. Thanks!

@caspervk
Copy link

@patrick91 what do you think about vendoring dependencies with strawberry instead of relying on a cdn?

@patrick91
Copy link
Member

@caspervk I think we thought about that, but each framework has it's own way to handle static files, I don't there's a nice way to handle them generically 🤔

@caspervk
Copy link

caspervk commented Mar 31, 2025

Right, it's annoying because there are no static files - it's just a html string through get_graphql_ide_html. To keep it a single file you could in-line the dependencies directly in the html - that'd perhaps be okay for GraphiQL, but I don't know how much css/js the other IDEs pull.

@caspervk
Copy link

caspervk commented Mar 31, 2025

How about something like

def get_graphql_ide_html(
    graphql_ide: Optional[GraphQL_IDE] = "graphiql",
) -> str:
    here = pathlib.Path(__file__).parents[1]

    if graphql_ide == "apollo-sandbox":
        path = here / "static/apollo-sandbox.html"
    elif graphql_ide == "pathfinder":
        path = here / "static/pathfinder.html"
    else:
        path = here / "static/graphiql.html"
 
-    return path.read_text(encoding="utf-8")
+    template = path.read_text(encoding="utf-8")
+
+    template = template.replace(
+        "{{ graphiql.min.css }}",
+        (here / "static/vendor/graphiql.min.css").read_text(encoding="utf-8"),
+    )
+    template = template.replace(
+        "{{ graphiql.min.js }}",
+        (here / "static/vendor/graphiql.min.js").read_text(encoding="utf-8"),
+    )
+
+    return template

or is it too dumb 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants