The Ontotext GraphQL Playground is a project designed to provide an intuitive interface for exploring and interacting with GraphQL APIs. It builds on a forked repository of GraphiQL and enhances it with additional functionality by integrating it into a reusable StencilJS-based web component. This setup ensures flexibility, reusability, and compatibility with other Ontotext projects, starting with the GraphDB Workbench.
The project is organized as follows:
-
graphiql/
(Submodule)
A forked version of the popular GraphiQL library. This submodule contains the core GraphQL playground functionality and acts as the foundation for this project. -
ontotext-graphql-playground-component/
A StencilJS web component that wraps thegraphiql
library and publishes it to npm for use in other projects. This component provides a framework-agnostic way to embed the GraphQL Playground in various applications.
The project development workflow follows these steps:
-
Clone the repository, including the submodule:
git clone --recurse-submodules https://github.com/Ontotext-AD/ontotext-graphql-playground
Note: You need an SSH public key registered with your Git account and sufficient permissions to access the submodule repository.
-
If the submodule is not initialized, run:
git submodule update --init --recursive
- The
graphiql
submodule resides in its own folder and can be updated or customized as needed. - Make changes in the forked repository to introduce Ontotext-specific features.
- Ensure compatibility with the StencilJS component by maintaining API stability.
Check out stenciljs docs here.
-
In the root directory install dependencies:
npm install
This script will:
- Navigate to the
graphiql
submodule and install dependencies withyarn
. - Navigate to the
ontotext-graphql-playground-component
directory and install its dependencies withnpm
.
- Navigate to the
-
Start the development server:
npm run start
This script will:
- Navigate to the
graphiql
submodule and build all bundles withyarn
. - Navigate to the
ontotext-graphql-playground-component
directory, copy all artifacts fromgraphiql
build, build and start the component withnpm
.
- Navigate to the
-
Update the StencilJS component to wrap
graphiql
features with Ontotext-specific styling and behavior.
To build and publish the StencilJS component, follow these steps:
-
Prepare Dependencies
- First, navigate to the root directory to install the project. Run
npm install
-
Build the Component
- Build both projects. Run:
npm run build
-
Assets The build step takes care of obtaining the assets needed for the component to build and run successfully. It copies these files into the
ontotext-graphql-playground-component/src/components/assets
directory- from
graphiql
graphiql.min.css
graphiql.min.js
- from
graphiql-plugin-explorer
index.umd.js
(renamed toexplorer.index.umd.js
)style.css
(renamed toexplorer.style.css
)
- from
npm-modules
ofontotext-graphql-playground-component
(as dev dependencies):react.development.js
react-dom.development.js
- from
-
Assets Output
- During the build process, assets files are copied to:
dist/ontotext-graphql-playground-component/assets
- During the build process, assets files are copied to:
-
Publish to npm
- Publish the built component to npm:
npm publish
- Publish the built component to npm:
-
Integration
- Once published, use the component in other projects, such as the GraphDB Workbench.
// TODO describe with cypress install
To integrate the Ontotext GraphQL Playground Component into another project, follow these steps:
Run the following command in your project directory to install the component:
npm install ontotext-graphql-playground-component
The component will attempt to load the required files from the assets
folder. You must ensure these files are copied to the correct location in your project during the build process.
Add the following configuration to your Webpack setup to copy the required assets:
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
// ... other Webpack config
plugins: [
new CopyPlugin({
patterns: [
{
from: 'node_modules/ontotext-graphql-playground-component/dist/ontotext-graphql-playground-component/assets',
to: 'assets',
},
],
}),
],
};
// TODO add description
-
Submodule Management
- Always update the
graphiql
submodule in sync with the upstream fork. - Test thoroughly after any updates to ensure no breaking changes affect the StencilJS component.
- Always update the
-
Code Consistency
- Development in the
graphiql
must comply with the practices and standards in that project. This is needed to prevent spreading unwanted changes in the codebase, hence preventing conflicts during upgrade. - Use linting tools for consistent code formatting:
npm run lint
- Development in the
-
Component Reusability
- Design the StencilJS component to be modular and easy to configure.
- Provide detailed documentation and examples in the component's
README.md
.
-
Documentation
- Keep this README up to date with the latest project structure and workflow.
- Include detailed comments in the code to explain Ontotext-specific changes.
-
CI/CD // TODO describe CI/CD
-
Version Control // TODO describe and add GitHub template