{"version":3,"sources":["CustomArgs.js","App.js","serviceWorker.js","index.js"],"names":["unwrapOutputType","outputType","unwrappedType","isWrappingType","ofType","makeDefaultArg","parentField","arg","type","name","startsWith","endsWith","getDefaultScalarArgValue","argType","kind","value","isEnumType","getValues","map","x","includes","GraphiQLExplorer","defaultValue","fetcher","params","fetch","method","headers","Accept","Content-Type","body","JSON","stringify","then","response","text","responseBody","parse","e","DEFAULT_QUERY","App","state","schema","query","explorerIsOpen","_handleInspectOperation","cm","mousePos","parsedQuery","_this","console","error","token","getTokenAt","start","line","ch","end","position","indexFromPos","def","definitions","find","definition","loc","log","_definition$loc","operationKind","operation","operationName","selector","concat","el","document","querySelector","scrollIntoView","_handleEditQuery","setState","_handleToggleExplorer","_this2","this","getIntrospectionQuery","result","editor","_graphiql","getQueryEditor","setOption","Object","objectSpread","options","extraKeys","Shift-Alt-LeftClick","buildClientSchema","data","_this3","_this$state","react_default","a","createElement","className","dist_default","onEdit","onRunOperation","handleRunQuery","onToggleExplorer","esm","ref","onEditQuery","Toolbar","Button","onClick","handlePrettifyQuery","label","title","handleToggleHistory","Component","Boolean","window","location","hostname","match","ReactDOM","render","src_App_0","getElementById","navigator","serviceWorker","ready","registration","unregister"],"mappings":"6UAeA,SAASA,EAAiBC,GAExB,IADA,IAAIC,EAAgBD,EACbE,YAAeD,IACpBA,EAAgBA,EAAcE,OAEhC,OAAOF,EAGF,SAASG,EACdC,EACAC,GAEA,IAAML,EAAgBF,EAAiBM,EAAYE,MACnD,SACEN,EAAcO,KAAKC,WAAW,YAC9BR,EAAcO,KAAKE,SAAS,eACd,UAAbJ,EAAIE,MAAiC,YAAbF,EAAIE,MAO1B,SAASG,EACdN,EACAC,EACAM,GAEA,IAAMX,EAAgBF,EAAiBM,EAAYE,MACnD,OAAQN,EAAcO,MACpB,IAAK,mBACH,GAAiB,SAAbF,EAAIE,KACN,MAAO,CAAEK,KAAM,cAAeC,MAAO,cAChC,GAAiB,UAAbR,EAAIE,KACb,MAAO,CAAE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AAjC,GAAa,OAC3ByB,EAAKV,UAAUmB,eAAelC,IAEhCzB,eAAgBoC,KAAKvC,MAAMG,eAC3B4D,iBAAkBxB,KAAKF,sBACvBlE,yBAA0BA,EAC1BP,eAAgBA,IAElB2F,EAAAC,EAAAC,cAACO,EAAA,EAAD,CACEC,IAAK,SAAAA,GAAG,OAAKZ,EAAKV,UAAYsB,GAC9BnF,QAASA,EACTmB,OAAQA,EACRC,MAAOA,EACPgE,YAAa3B,KAAKJ,kBAElBoB,EAAAC,EAAAC,cAACO,EAAA,EAASG,QAAV,KACEZ,EAAAC,EAAAC,cAACO,EAAA,EAASI,OAAV,CACEC,QAAS,kBAAMhB,EAAKV,UAAU2B,uBAC9BC,MAAM,WACNC,MAAM,kCAERjB,EAAAC,EAAAC,cAACO,EAAA,EAASI,OAAV,CACEC,QAAS,kBAAMhB,EAAKV,UAAU8B,uBAC9BF,MAAM,UACNC,MAAM,iBAERjB,EAAAC,EAAAC,cAACO,EAAA,EAASI,OAAV,CACEC,QAAS9B,KAAKF,sBACdkC,MAAM,WACNC,MAAM,8BAvHFE,aClCEC,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAO1B,EAAAC,EAAAC,cAACyB,EAAD,MAASlD,SAASmD,eAAe,SD2H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAM9F,KAAK,SAAA+F,GACjCA,EAAaC","file":"static/js/main.393a73e0.chunk.js","sourcesContent":["// flow\n\nimport GraphiQLExplorer from \"graphiql-explorer\";\nimport { isEnumType, isWrappingType } from \"graphql\";\n\nimport type {\n GraphQLField,\n GraphQLArgument,\n GraphQLInputField,\n GraphQLEnumType,\n GraphQLOutputType,\n GraphQLScalarType,\n ValueNode\n} from \"graphql\";\n\nfunction unwrapOutputType(outputType: GraphQLOutputType): * {\n let unwrappedType = outputType;\n while (isWrappingType(unwrappedType)) {\n unwrappedType = unwrappedType.ofType;\n }\n return unwrappedType;\n}\n\nexport function makeDefaultArg(\n parentField: GraphQLField,\n arg: GraphQLArgument | GraphQLInputField\n): boolean {\n const unwrappedType = unwrapOutputType(parentField.type);\n if (\n unwrappedType.name.startsWith(\"GitHub\") &&\n unwrappedType.name.endsWith(\"Connection\") &&\n (arg.name === \"first\" || arg.name === \"orderBy\")\n ) {\n return true;\n }\n return false;\n}\n\nexport function getDefaultScalarArgValue(\n parentField: GraphQLField,\n arg: GraphQLArgument | GraphQLInputField,\n argType: GraphQLEnumType | GraphQLScalarType\n): ValueNode {\n const unwrappedType = unwrapOutputType(parentField.type);\n switch (unwrappedType.name) {\n case \"GitHubRepository\":\n if (arg.name === \"name\") {\n return { kind: \"StringValue\", value: \"graphql-js\" };\n } else if (arg.name === \"owner\") {\n return { kind: \"StringValue\", value: \"graphql\" };\n }\n break;\n case \"NpmPackage\":\n if (arg.name === \"name\") {\n return { kind: \"StringValue\", value: \"graphql\" };\n }\n break;\n default:\n if (\n isEnumType(argType) &&\n unwrappedType.name.startsWith(\"GitHub\") &&\n unwrappedType.name.endsWith(\"Connection\")\n ) {\n if (\n arg.name === \"direction\" &&\n argType\n .getValues()\n .map(x => x.name)\n .includes(\"DESC\")\n ) {\n return { kind: \"EnumValue\", value: \"DESC\" };\n } else if (\n arg.name === \"field\" &&\n argType\n .getValues()\n .map(x => x.name)\n .includes(\"CREATED_AT\")\n ) {\n return { kind: \"EnumValue\", value: \"CREATED_AT\" };\n }\n }\n return GraphiQLExplorer.defaultValue(argType);\n }\n return GraphiQLExplorer.defaultValue(argType);\n}\n","// @flow\n\nimport React, { Component } from \"react\";\nimport GraphiQL from \"graphiql\";\nimport GraphiQLExplorer from \"graphiql-explorer\";\nimport { buildClientSchema, getIntrospectionQuery, parse } from \"graphql\";\n\nimport { makeDefaultArg, getDefaultScalarArgValue } from \"./CustomArgs\";\n\nimport \"graphiql/graphiql.css\";\nimport \"./App.css\";\n\nimport type { GraphQLSchema } from \"graphql\";\n\nfunction fetcher(params: Object): Object {\n return fetch(\n \"/v3/graphql\",\n {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }\n )\n .then(function(response) {\n return response.text();\n })\n .then(function(responseBody) {\n try {\n return JSON.parse(responseBody);\n } catch (e) {\n return responseBody;\n }\n });\n}\n\nconst DEFAULT_QUERY = ``;\n\ntype State = {\n schema: ?GraphQLSchema,\n query: string,\n explorerIsOpen: boolean\n};\n\nclass App extends Component<{}, State> {\n _graphiql: GraphiQL;\n state = { schema: null, query: DEFAULT_QUERY, explorerIsOpen: true };\n\n componentDidMount() {\n fetcher({\n query: getIntrospectionQuery()\n }).then(result => {\n const editor = this._graphiql.getQueryEditor();\n editor.setOption(\"extraKeys\", {\n ...(editor.options.extraKeys || {}),\n \"Shift-Alt-LeftClick\": this._handleInspectOperation\n });\n\n this.setState({ schema: buildClientSchema(result.data) });\n });\n }\n\n _handleInspectOperation = (\n cm: any,\n mousePos: { line: Number, ch: Number }\n ) => {\n const parsedQuery = parse(this.state.query || \"\");\n\n if (!parsedQuery) {\n console.error(\"Couldn't parse query document\");\n return null;\n }\n\n var token = cm.getTokenAt(mousePos);\n var start = { line: mousePos.line, ch: token.start };\n var end = { line: mousePos.line, ch: token.end };\n var relevantMousePos = {\n start: cm.indexFromPos(start),\n end: cm.indexFromPos(end)\n };\n\n var position = relevantMousePos;\n\n var def = parsedQuery.definitions.find(definition => {\n if (!definition.loc) {\n console.log(\"Missing location information for definition\");\n return false;\n }\n\n const { start, end } = definition.loc;\n return start <= position.start && end >= position.end;\n });\n\n if (!def) {\n console.error(\n \"Unable to find definition corresponding to mouse position\"\n );\n return null;\n }\n\n var operationKind =\n def.kind === \"OperationDefinition\"\n ? def.operation\n : def.kind === \"FragmentDefinition\"\n ? \"fragment\"\n : \"unknown\";\n\n var operationName =\n def.kind === \"OperationDefinition\" && !!def.name\n ? def.name.value\n : def.kind === \"FragmentDefinition\" && !!def.name\n ? def.name.value\n : \"unknown\";\n\n var selector = `.graphiql-explorer-root #${operationKind}-${operationName}`;\n\n var el = document.querySelector(selector);\n el && el.scrollIntoView();\n };\n\n _handleEditQuery = (query: string): void => this.setState({ query });\n\n _handleToggleExplorer = () => {\n this.setState({ explorerIsOpen: !this.state.explorerIsOpen });\n };\n\n render() {\n const { query, schema } = this.state;\n return (\n
\n \n this._graphiql.handleRunQuery(operationName)\n }\n explorerIsOpen={this.state.explorerIsOpen}\n onToggleExplorer={this._handleToggleExplorer}\n getDefaultScalarArgValue={getDefaultScalarArgValue}\n makeDefaultArg={makeDefaultArg}\n />\n (this._graphiql = ref)}\n fetcher={fetcher}\n schema={schema}\n query={query}\n onEditQuery={this._handleEditQuery}\n >\n \n this._graphiql.handlePrettifyQuery()}\n label=\"Prettify\"\n title=\"Prettify Query (Shift-Ctrl-P)\"\n />\n this._graphiql.handleToggleHistory()}\n label=\"History\"\n title=\"Show History\"\n />\n \n \n \n
\n );\n }\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read http://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === \"[::1]\" ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === \"production\" && \"serviceWorker\" in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener(\"load\", () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n \"This web app is being served cache-first by a service \" +\n \"worker. To learn more, visit http://bit.ly/CRA-PWA\"\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === \"installed\") {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n \"New content is available and will be used when all \" +\n \"tabs for this page are closed. See http://bit.ly/CRA-PWA.\"\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log(\"Content is cached for offline use.\");\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error(\"Error during service worker registration:\", error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get(\"content-type\");\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf(\"javascript\") === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n \"No internet connection found. App is running in offline mode.\"\n );\n });\n}\n\nexport function unregister() {\n if (\"serviceWorker\" in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport \"./index.css\";\nimport App from \"./App\";\nimport * as serviceWorker from \"./serviceWorker\";\n\nReactDOM.render(, document.getElementById(\"root\"));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: http://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}