{"id":13499152,"url":"https://github.com/rse/hapi-plugin-graphiql","last_synced_at":"2025-04-19T09:59:14.141Z","repository":{"id":66345605,"uuid":"71045223","full_name":"rse/hapi-plugin-graphiql","owner":"rse","description":"HAPI plugin for GraphiQL integration","archived":false,"fork":false,"pushed_at":"2020-09-03T23:22:33.000Z","size":1466,"stargazers_count":21,"open_issues_count":4,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T00:43:01.247Z","etag":null,"topics":["graphiql","graphql","hapi","plugin"],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-16T11:08:42.000Z","updated_at":"2025-02-11T21:32:54.000Z","dependencies_parsed_at":"2023-04-11T08:16:47.298Z","dependency_job_id":null,"html_url":"https://github.com/rse/hapi-plugin-graphiql","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":0.04395604395604391,"last_synced_commit":"1348120bc90961c62b228bf11f643e6f2d4a9eb5"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fhapi-plugin-graphiql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fhapi-plugin-graphiql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fhapi-plugin-graphiql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fhapi-plugin-graphiql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rse","download_url":"https://codeload.github.com/rse/hapi-plugin-graphiql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248289731,"owners_count":21078918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphiql","graphql","hapi","plugin"],"created_at":"2024-07-31T22:00:29.997Z","updated_at":"2025-04-19T09:59:14.118Z","avatar_url":"https://github.com/rse.png","language":"CSS","readme":"\nhapi-plugin-graphiql\n====================\n\n[HAPI](http://hapijs.com/) plugin for [GraphiQL](https://github.com/graphql/graphiql) integration\n\n\u003cp/\u003e\n\u003cimg src=\"https://nodei.co/npm/hapi-plugin-graphiql.png?downloads=true\u0026stars=true\" alt=\"\"/\u003e\n\n\u003cp/\u003e\n\u003cimg src=\"https://david-dm.org/rse/hapi-plugin-graphiql.png\" alt=\"\"/\u003e\n\n\u003cimg src=\"screenshot.png\" alt=\"\"/\u003e\n\nInstallation\n------------\n\n```shell\n$ npm install hapi hapi-plugin-graphiql\n```\n\nAbout\n-----\n\nThis is a small plugin for the [HAPI](http://hapijs.com/)\nserver framework for seamless integration of\n[GraphiQL](https://github.com/graphql/graphiql), an interactive\n[GraphQL](http://graphql.org/) user interface. This variant of GraphiQL\nespecially integrates a username/password based login dialog and reports\nnetwork responses in the GraphiQL status bar. In case of its\ndownstream/local copy of GraphiQL, it also applies some [additional\nchanges to GraphiQL's internals](local/).\n\nUsage\n-----\n\nThe following example shows the plugin in action.\nThe shown options are actually the default ones:\n\n```js\nserver.register({\n    register: require(\"hapi-plugin-graphiql\"),\n    options: {\n        graphiqlSource: \"downstream\",\n        graphiqlGlobals: \"\",\n        graphiqlURL: \"/api\",\n        graphqlFetchURL: \"/api/data/graph\",\n        graphqlFetchOpts: `{\n            method: \"POST\",\n            headers: {\n                \"Content-Type\": \"application/json\",\n                \"Accept\":       \"application/json\"\n            },\n            body: JSON.stringify(params),\n            credentials: \"same-origin\"\n        }`,\n        loginFetchURL: \"/api/auth/login\",\n        loginFetchOpts: `{\n            method: \"POST\",\n            headers: {\n                \"Content-Type\": \"application/json\"\n            },\n            body: JSON.stringify({\n                username: username,\n                password: password\n            }),\n            credentials: \"same-origin\"\n        }`,\n        loginFetchSuccess: \"\",\n        loginFetchError: \"\",\n        graphqlExample:\n            \"query Example {\\n\" +\n            \"    Session {\\n\" +\n            \"        __typename # schema introspection\\n\" +\n            \"    }\\n\" +\n            \"}\\n\",\n        documentationURL:  \"\",\n        documentationFile: \"\"\n    }\n})\n```\n\nThis assumes you have a REST-based authentication endpoint\n`/api/auth/login` and a GraphQL endpoint `/api/data/graphql`. The\nGraphiQL UI then can be accessed under `/api`. The authentication\nendpoint is assumed to accept `{ username: \"...\", password: \"...\" }` and\nsets the authentication token as a HTTP cookie for `/api`. If you your\nauthentication endpoint returns `{ token: \"...\" }` and the token has to be passed in an\n`Authorization` header as a Bearer token, use the following configuration instead:\n\n```js\nserver.register({\n    register: require(\"hapi-plugin-graphiql\"),\n    options: {\n        graphiqlSource: \"downstream\",\n        graphiqlGlobals: `var token = null;`,\n        graphiqlURL: \"/api\",\n        graphqlFetchURL: \"/api/data/graph\",\n        graphqlFetchOpts: `{\n            method: \"POST\",\n            headers: Object.assign({\n                \"Content-Type\":  \"application/json\",\n                \"Accept\":        \"application/json\"\n            }, token ? {\n                \"Authorization\": \"Bearer \" + token\n            } : {}),\n            body: JSON.stringify(params),\n            credentials: \"same-origin\"\n        }`,\n        loginFetchURL: \"/api/auth/login\",\n        loginFetchOpts: `{\n            method: \"POST\",\n            headers: {\n                \"Content-Type\": \"application/json\"\n            },\n            body: JSON.stringify({\n                username: username,\n                password: password\n            }),\n            credentials: \"same-origin\"\n        }`,\n        loginFetchSuccess: `token = JSON.parse(response.text()).token;`,\n        loginFetchError:   `token = null;`,\n        graphqlExample:\n            \"query Example {\\n\" +\n            \"    Session {\\n\" +\n            \"        __typename # schema introspection\\n\" +\n            \"    }\\n\" +\n            \"}\\n\"\n    }\n})\n```\n\nOptions\n-------\n\nThe supported configuration options are:\n\n- `graphiqlSource`:\u003cbr/\u003e\n  The source for GraphiQL, either `upstream` (original vendor version) or\n  `downstream` ([patched local version](local/)).\n  Default: `\"downstream\"`\n\n- `graphiqlGlobals`:\u003cbr/\u003e\n  JavaScript code snippet injected into the global scope of the GraphiQL integration.\n  Usually used for injecting a global variable for use in the other code snippets.\n  Default: `\"\"`\n\n- `graphiqlURL`:\u003cbr/\u003e\n  The URL under which the GraphiQL UI is registered for `GET` requests.\n  This can be even the same as the GraphQL URL, as it is usually registered for `POST` requests.\n  Default: `\"/api\"`\n\n- `graphqlFetchURL`:\u003cbr/\u003e\n  The URL under which the GraphQL API can be reached via `POST` requests.\n  Default: `\"/api/data/graph\"`\n\n- `graphqlFetchOpts`:\u003cbr/\u003e\n  JavaScript code snippet injected into the W3C-Fetch API call as options\n  for fetching a GraphQL query.\n  Default:\n\n    ```\n    `{\n        method: \"POST\",\n        headers: {\n            \"Content-Type\": \"application/json\",\n            \"Accept\":       \"application/json\"\n        },\n        body: JSON.stringify(params),\n        credentials: \"same-origin\"\n    }`\n    ```\n\n- `loginFetchURL`:\u003cbr/\u003e\n  JavaScript code snippet injected into the W3C-Fetch API call as options\n  for logging in.\n  Default: `\"/api/auth/login\"`\n\n- `loginFetchOpts`:\u003cbr/\u003e\n  JavaScript code snippet injected into the W3C-Fetch API call as options\n  for logging in.\n  Default:\n\n    ```\n    `{\n        method: \"POST\",\n        headers: {\n            \"Content-Type\": \"application/json\"\n        },\n        body: JSON.stringify({\n            username: username,\n            password: password\n        }),\n        credentials: \"same-origin\"\n    }`\n    ```\n\n- `loginFetchSuccess`:\u003cbr/\u003e\n  JavaScript code snippet injected into the success handler of the W3C-Fetch API call\n  for loggin in.\n  Default: `\"\"`\n\n- `loginFetchError`:\u003cbr/\u003e\n  JavaScript code snippet injected into the error handler of the W3C-Fetch API call\n  for loggin in.\n  Default: `\"\"`\n\n- `graphqlExample`:\u003cbr/\u003e\n  A GraphQL query string used as the initial query source in the UI.\n  Default:\n\n    ```\n    \"query Example {\\n\" +\n    \"    Session {\\n\" +\n    \"        __typename # schema introspection\\n\" +\n    \"    }\\n\" +\n    \"}\\n\"\n    ```\n\n- `documentationURL`:\u003cbr/\u003e\n   URL (usually under `graphiqlURL`) under which you want\n   to reference a single documentation file with the markdown\n   directive `[name](url)` from within your GraphQL schema comments.\n\n- `documentationFile`:\u003cbr/\u003e\n  The local path to the file to serve if `documentationURL` is requested.\n\nLicense\n-------\n\nCopyright (c) 2016-2019 Dr. Ralf S. Engelschall (http://engelschall.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","funding_links":[],"categories":["Libraries","Implementations"],"sub_categories":["JavaScript Libraries","JavaScript/TypeScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fhapi-plugin-graphiql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frse%2Fhapi-plugin-graphiql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fhapi-plugin-graphiql/lists"}