Skip to content
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

Make schema extensible #3

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ _scripts/
*.egg-info/
*.log
*.tar.gz
*.tsbuildinfo
envs/
lib/
Untitled*.ipynb
node_modules/
static/
Untitled*.ipynb
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bracketSpacing: false
printWidth: 88
semi: true
singleQuote: true

overrides:
- files: "*.ts"
options:
arrowParens: always
trailingComma: es5
- files: "*.css"
options:
singleQuote: false
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## Unreleased

### 0.2.0

- Subscriptions (in server and GraphiQL)

### 0.1.0

- Basic Capability with contents manager
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# jupyter-graphql

## demos on <img src="https://mybinder.org/static/logo.svg?v=f9f0d927b67cc9dc99d788c822ca21c0" height="30px"/>

- [GraphQL in the Notebook][]
- [GraphiQL][]

## what the...

A very experimental Jupyter notebook server extension for exposing things in
GraphQL. Heavily copied from https://github.com/dronedeploy/graphene-tornado

- [ ] ContentsManager
- [x] get (mostly focused on Notebook)

## i can't even...

```bash
git clone https://github.com/deathbeds/jupyter-graphql
cd jupyter-graphql
Expand All @@ -24,6 +27,5 @@ jupyter lab

And navigate to `http://localhost:8888/graphql` to play around.

[GraphQL in the Notebook]: https://mybinder.org/v2/gh/deathbeds/jupyter-graphql/master?urlpath=lab/tree/notebooks/gql.ipynb

[graphql in the notebook]: https://mybinder.org/v2/gh/deathbeds/jupyter-graphql/master?urlpath=lab/tree/notebooks/gql.ipynb
[graphiql]: https://mybinder.org/v2/gh/deathbeds/jupyter-graphql/master?urlpath=graphql
54 changes: 32 additions & 22 deletions anaconda-project.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
name: jupyter-graphql-dev

variables:
PY_SRC: src setup.py

commands:
lab:
unix: jupyter lab --no-browser --debug
setup:
unix: pip install -e . --ignore-installed --no-deps
black:
unix: black src/py setup.py
lint:
unix: isort -rc $PY_SRC && black $PY_SRC && jlpm lint
atom:
unix: atom .
static:
unix: python -m jupyter_graphql.fetch_static

env_specs:
default:
platforms:
- linux-64
- osx-64
- win-64
inherit_from:
- jupyter-graphql-dev
- jupyter-graphql-dev
platforms:
- linux-64
- osx-64
- win-64
packages:
- black
- flake8
- beautysh
- black
- flake8
- beautysh
- isort
jupyter-graphql-dev:
packages:
- gql
- graphene
- iso8601
- jupyterlab >=0.35,<0.36
- python >=3.6,<3.7
- requests
- werkzeug
- pip:
- graphql-ws
- graphene-tornado
- gql
- graphene
- iso8601
- jupyterlab >=0.35,<0.36
- nodejs >=8,<9
- pandas
- pyld
- python >=3.6,<3.7
- rdflib-jsonld
- requests
- requests-cache
- werkzeug
- pip:
- graphql-ws
- graphene-tornado
channels:
- conda-forge
- defaults
- conda-forge
- defaults
- bioconda
10 changes: 8 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ name: jupyter-graphql-dev
channels:
- conda-forge
- defaults
- bioconda

dependencies:
- gql
- graphene
- iso8601
- jupyterlab >=0.35,<0.36
- nodejs >=8,<9
- pandas
- pyld
- python >=3.6,<3.7
- rdflib-jsonld
- requests
- requests-cache
- werkzeug
- pip:
- graphql-ws
- graphene-tornado
- graphql-ws
- graphene-tornado
1 change: 1 addition & 0 deletions labex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./packages/jupyterlab-graphql
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"packages": ["packages/*"],
"version": "independent",
"npmClient": "jlpm",
"registry": "https://registry.npmjs.org/",
"useWorkspaces": true
}
47 changes: 47 additions & 0 deletions notebooks/GraphQL Editor.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# JupyterLab GraphQL Editor\n",
"[jupyterlab-graphql](../packages/jupyterlab-graphql/README.md) provides an interactive development experience similar to the [GraphQL Playground](https://www.graphqlbin.com) or [Graph$i$QL](https://graphql.github.io/swapi-graphql/), but native (ish) to JupyterLab.\n",
"\n",
"> There are still some awful hacks"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive Examples\n",
"- [All the files in the `notebooks` directory](./Notebooks.graphql) \n",
"- [The source of this notebook](./Notebooks.graphql) \n",
"- [This notebook as markdown](./Markdown.graphql)\n",
"\n",
"> You will also need [jupyter-graphql](../README.md) installed and configured, or otherwise start a GraphQL server."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
7 changes: 7 additions & 0 deletions notebooks/Markdown.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query {
nbconvert {
markdown(path: "notebooks/GraphQL Editor.ipynb") {
output
}
}
}
13 changes: 13 additions & 0 deletions notebooks/Notebooks.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query {
contents(path: "notebooks") {
... on DirectoryContents {
content {
edges {
node {
path
}
}
}
}
}
}
15 changes: 15 additions & 0 deletions notebooks/Playground.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
query {
contents(path: "notebooks/GraphQL Editor.ipynb") {
... on NotebookContents {
content {
cells {
edges {
node {
source
}
}
}
}
}
}
}
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "jupyter-graphql",
"private": true,
"version": "2019.03",
"devDependencies": {
"lerna": "^3.13.1",
"typescript": "^3.4",
"prettier": "1.16.4"
},
"workspaces": [
"packages/*"
],
"scripts": {
"bootstrap": "jlpm --no-optional && jlpm lerna bootstrap && jlpm build",
"build": "lerna run build --stream",
"watch": "lerna run --stream --parallel --prefix watch",
"lint": "jlpm prettier",
"prettier": "prettier --write *.json *.md *.yml && lerna exec --stream -- prettier --write --config=../../.prettierrc ./src/**/*.ts ./style/**/*.css ./*.json ./*.md"
}
}
4 changes: 4 additions & 0 deletions packages/jupyterlab-graphql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# jupyterlab-graphql

GraphQL syntax highlighting for and interactive exploration like _GraphIQL_ or
_GraphQL Playground_.
55 changes: 55 additions & 0 deletions packages/jupyterlab-graphql/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"author": "Dead Pixels Collective",
"bugs": {
"url": "https://github.com/deathbeds/jupyter-graphql/issues"
},
"description": "GraphQL Syntax Highlighting and Exploration for JupyterLab",
"dependencies": {
"codemirror-graphql": "^0.8.3",
"graphql": "*"
},
"devDependencies": {
"@jupyterlab/application": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"@types/codemirror": "^0.0.71",
"@types/graphql": "14.2.0",
"codemirror": "~5.39.0",
"@types/node": "^9.4.2",
"@types/webpack-env": "~1.13.6",
"@jupyterlab/rendermime-interfaces": "^1.2.1"
},
"files": [
"{lib,style}/**/*.{css,d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}"
],
"jupyterlab": {
"extension": "lib/plugin.js"
},
"license": "BSD-3-Clause",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension",
"codemirror",
"graphql"
],
"main": "lib/index.js",
"name": "@deathbeds/jupyterlab-graphql",
"peerDependencies": {
"@jupyterlab/application": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"codemirror": "~5.39.0",
"@jupyterlab/rendermime-interfaces": "^1.2.1"
},
"homepage": "https://github.com/deathbeds/jupyter-graphql",
"repository": {
"type": "git",
"url": "https://github.com/deathbeds/jupyter-graphql.git"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"lint": "tslint --project ."
},
"types": "lib/index.d.ts",
"version": "0.1.0"
}
33 changes: 33 additions & 0 deletions packages/jupyterlab-graphql/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export const PLUGIN_NS = '@deathbeds/jupyterlab-graphql';
export const PLUGIN_ID = `${PLUGIN_NS}:plugin`;
export const MIME_ID_TMPL = `${PLUGIN_NS}:mime:`;

export const MIME_GRAPHQL = 'application/graphql';
export const FACTORY_GRAPHQL = 'GraphQLExplorer';

export const CMD = {
NEW_DOC: 'docmanager:new-untitled',
OPEN_DOC: 'docmanager:open',
NEW_GV: 'graphviz:new-untitled',
GQL_DOCS: 'graphql:docs',
GQL_SCHEMA: 'graphql:schema'
};

export const CSS = {
ICON: 'jp-GraphQLIcon',
DOC: 'jp-GraphQL',
URL: 'jp-GraphQL-URL',
EDIT: 'jp-GraphQL-Editor',
POP: 'jp-GraphQL-PopIcon',
SCHEMA: 'jp-GraphQL-Schema',
DOCS: 'jp-GraphQL-Docs'
};

export const TYPES = {
[MIME_GRAPHQL]: {
name: 'graphql',
mimeTypes: [MIME_GRAPHQL],
extensions: ['.graphql'],
iconClass: CSS.ICON,
},
};
Empty file.
9 changes: 9 additions & 0 deletions packages/jupyterlab-graphql/src/mode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module 'codemirror/addon/hint/show-hint' {}
declare module 'codemirror/addon/lint/lint' {}
declare module 'codemirror-graphql/hint' {}
declare module 'codemirror-graphql/lint' {}
declare module 'codemirror-graphql/mode' {}

declare module 'codemirror/addon/fold/foldcode' {}
declare module 'codemirror/addon/fold/foldgutter' {}
declare module 'codemirror/addon/fold/brace-fold' {}