Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
graphql-playground-html
Advanced tools
GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
The graphql-playground-html npm package provides a way to embed GraphQL Playground, a powerful GraphQL IDE, into your web applications. It allows developers to interact with their GraphQL APIs through a user-friendly interface, making it easier to test queries, mutations, and subscriptions.
Embedding GraphQL Playground
This code sample demonstrates how to embed GraphQL Playground into an HTML page. It includes the necessary CSS and JavaScript files from a CDN and initializes the playground with a specified GraphQL endpoint.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>GraphQL Playground</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/css/index.css" />
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/favicon.png" />
<script src="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/js/middleware.js"></script>
</head>
<body>
<div id="root"></div>
<script>
window.addEventListener('load', function (event) {
GraphQLPlayground.init(document.getElementById('root'), { endpoint: '/graphql' })
})
</script>
</body>
</html>
Customizing GraphQL Playground
This code sample shows how to customize the GraphQL Playground by setting various options such as the editor theme and cursor shape. These settings can be adjusted to fit the developer's preferences.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>GraphQL Playground</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/css/index.css" />
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/favicon.png" />
<script src="https://cdn.jsdelivr.net/npm/graphql-playground-html@latest/build/static/js/middleware.js"></script>
</head>
<body>
<div id="root"></div>
<script>
window.addEventListener('load', function (event) {
GraphQLPlayground.init(document.getElementById('root'), {
endpoint: '/graphql',
settings: {
'editor.theme': 'dark',
'editor.cursorShape': 'line'
}
})
})
</script>
</body>
</html>
GraphiQL is another popular GraphQL IDE that provides a similar interface for testing and interacting with GraphQL APIs. It is highly customizable and can be embedded into web applications. Compared to graphql-playground-html, GraphiQL is more lightweight but may lack some of the advanced features and polish of GraphQL Playground.
Altair is a feature-rich GraphQL client that offers a wide range of functionalities, including query history, variable extraction, and more. It can be used as a standalone application or embedded into web applications. Altair provides a more extensive set of features compared to graphql-playground-html, making it suitable for more advanced use cases.
Apollo Server is a GraphQL server implementation that includes a built-in GraphQL Playground for testing queries and mutations. While it is primarily focused on serving GraphQL APIs, the included playground offers similar functionalities to graphql-playground-html. Apollo Server is a good choice if you need both a GraphQL server and an integrated playground.
FAQs
GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
The npm package graphql-playground-html receives a total of 229,884 weekly downloads. As such, graphql-playground-html popularity was classified as popular.
We found that graphql-playground-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.