Browse Source

Merge pull request #3335 from ondratra/olympia_graphql_playground_fix

Olympia graphql playground fix
Mokhtar Naamani 3 years ago
parent
commit
4d5b2916bc

+ 10 - 2
.env

@@ -24,8 +24,16 @@ BLOCK_HEIGHT=0
 # Query node GraphQL server port
 GRAPHQL_SERVER_PORT=8081
 
-# Query node playground subscription endpoint
-GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT=ws://localhost:8081/graphql
+# Query node playground endpoint
+# Leave it blank if you want endpoint to be copied from browser's URL
+GRAPHQL_PLAYGROUND_ENDPOINT=""
+
+# Query node playground subscription endpoint - will be derived from GRAPHQL_PLAYGROUND_ENDPOINT
+# when not set
+# GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT=ws://localhost:8081/graphql
+
+# URL for CDN serving QN Playground's JS/CSS files - set empty string for local file serving
+GRAPHQL_PLAYGROUND_CDN_URL=""
 
 # Hydra indexer gateway GraphQL server port
 HYDRA_INDEXER_GATEWAY_PORT=4000

+ 3 - 0
docker-compose.yml

@@ -173,6 +173,9 @@ services:
     environment:
       - DB_HOST=db
       - WARTHOG_APP_PORT=${GRAPHQL_SERVER_PORT}
+      - GRAPHQL_PLAYGROUND_ENDPOINT=${GRAPHQL_PLAYGROUND_ENDPOINT}
+      - GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT=${GRAPHQL_PLAYGROUND_SUBSCRIPTION_ENDPOINT}
+      - GRAPHQL_PLAYGROUND_CDN_URL=${GRAPHQL_PLAYGROUND_CDN_URL}
     ports:
       - "${GRAPHQL_SERVER_PORT}:${GRAPHQL_SERVER_PORT}"
     depends_on:

+ 1 - 2
package.json

@@ -46,8 +46,7 @@
     "rxjs": "^7.4.0",
     "typeorm": "0.2.34",
     "pg": "^8.4.0",
-    "chalk": "^4.0.0",
-    "@joystream/warthog": "2.41.2"
+    "chalk": "^4.0.0"
   },
   "devDependencies": {
     "eslint": "^7.25.0",

+ 1 - 0
query-node/build.sh

@@ -14,6 +14,7 @@ yarn --cwd codegen install
 
 yarn clean
 yarn codegen:noinstall
+cp mappings/queryTemplates.ts generated/graphql-server/src/
 yarn typegen # if this fails try to run this command outside of yarn workspaces
 
 # We run yarn again to ensure graphql-server dependencies are installed

+ 2 - 2
query-node/codegen/package.json

@@ -6,7 +6,7 @@
   "license": "ISC",
   "scripts": {},
   "dependencies": {
-    "@joystream/hydra-cli": "3.1.0-alpha.16",
-    "@joystream/hydra-typegen": "3.1.0-alpha.16"
+    "@joystream/hydra-cli": "^3.1.0-alpha.20",
+    "@joystream/hydra-typegen": "^3.1.0-alpha.20"
   }
 }

+ 17 - 17
query-node/codegen/yarn.lock

@@ -33,9 +33,9 @@
   dependencies:
     xss "^1.0.8"
 
-"@apollographql/graphql-playground-react@https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz":
-  version "1.7.28"
-  resolved "https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz#24c9c54e14ae0ba13c894738b4b87301f5801b26"
+"@apollographql/graphql-playground-react@https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz":
+  version "1.7.29"
+  resolved "https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz#bf0bf4a72f74de156ccf2a8638e7cb617a8b41e2"
   dependencies:
     "@types/lru-cache" "^4.1.1"
     apollo-link "^1.2.13"
@@ -306,15 +306,15 @@
   resolved "https://registry.yarnpkg.com/@josephg/resolvable/-/resolvable-1.0.1.tgz#69bc4db754d79e1a2f17a650d3466e038d94a5eb"
   integrity sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==
 
-"@joystream/hydra-cli@3.1.0-alpha.16":
-  version "3.1.0-alpha.16"
-  resolved "https://registry.yarnpkg.com/@joystream/hydra-cli/-/hydra-cli-3.1.0-alpha.16.tgz#3bebe326b2ae6ad96b821797ca699c581217ac45"
-  integrity sha512-2Dq5fBqJWdqE0OhvI/kBA0i3gngnDmd0AaSFhJ03LE3mKTvzhapaOyWmEgO9vqQCSopSi0wWorizzksnu2+GQw==
+"@joystream/hydra-cli@^3.1.0-alpha.20":
+  version "3.1.0-alpha.20"
+  resolved "https://registry.yarnpkg.com/@joystream/hydra-cli/-/hydra-cli-3.1.0-alpha.20.tgz#cb114994b6b74761164796540b6d64ad1096f219"
+  integrity sha512-NFDnNjt7E+HLpIBbKwJSh+1MZ+hZgGzPmLY6Ux+7lSW+g8DiMc7ZnuYRHkEEIUrDyiPTapKDF3bWmo5LD6lHQA==
   dependencies:
     "@inquirer/input" "^0.0.13-alpha.0"
     "@inquirer/password" "^0.0.12-alpha.0"
     "@inquirer/select" "^0.0.13-alpha.0"
-    "@joystream/warthog" "~2.41.2"
+    "@joystream/warthog" "^2.41.4"
     "@oclif/command" "^1.5.20"
     "@oclif/config" "^1"
     "@oclif/errors" "^1.3.3"
@@ -342,10 +342,10 @@
     pluralize "^8.0.0"
     tslib "1.11.2"
 
-"@joystream/hydra-typegen@3.1.0-alpha.16":
-  version "3.1.0-alpha.16"
-  resolved "https://registry.yarnpkg.com/@joystream/hydra-typegen/-/hydra-typegen-3.1.0-alpha.16.tgz#5756b714767be8f3b237dba270386113c64b1245"
-  integrity sha512-ik1iegF7qZXeumsJ8baeff5VAxgrc6+yyRIZNFgWrCRDVEnP613XNFpUIcKzuXme7BhCVeaY5ynLaQUtU6lcUw==
+"@joystream/hydra-typegen@^3.1.0-alpha.20":
+  version "3.1.0-alpha.20"
+  resolved "https://registry.yarnpkg.com/@joystream/hydra-typegen/-/hydra-typegen-3.1.0-alpha.20.tgz#dbfc608908fa3809a9904a8165281111b4a104f9"
+  integrity sha512-+hDsr2Ys+UoVuOLj0kCoUq3+DcNopgNkzxQ6c1o1EyAVh5/a5dmp/jjxpLkN/CvIKej19pZqM3q914G8rYi/7g==
   dependencies:
     "@oclif/command" "^1.8.0"
     "@oclif/config" "^1"
@@ -358,12 +358,12 @@
     yaml "^1.10.0"
     yaml-validator "^3.0.0"
 
-"@joystream/warthog@~2.41.2":
-  version "2.41.2"
-  resolved "https://registry.yarnpkg.com/@joystream/warthog/-/warthog-2.41.2.tgz#6d3cf5c977320d1c77be518e848e011a9699b22d"
-  integrity sha512-1w6aT5P3xiI/HaTtqJrVj4Yp1/gxG8cGTeYgzlwr3iq8J11skwE4rLCHQucHfVueyBX49AaqWrhl+wI2ACqk4Q==
+"@joystream/warthog@^2.41.4":
+  version "2.41.4"
+  resolved "https://registry.yarnpkg.com/@joystream/warthog/-/warthog-2.41.4.tgz#4b0a396d9d6eee9e469a36b1ca1c86c3890d56d6"
+  integrity sha512-yfGgrjbg3alGR+7g1NcSTdlpYtgH0kDFNDSKFWiYFEPNsjwwCBgWnsVQ+ED1PWAa2RhUhwp9J4dsI5U21P543A==
   dependencies:
-    "@apollographql/graphql-playground-react" "https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz"
+    "@apollographql/graphql-playground-react" "https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz"
     "@types/app-root-path" "^1.2.4"
     "@types/bn.js" "^4.11.6"
     "@types/caller" "^1.0.0"

+ 3 - 3
query-node/mappings/package.json

@@ -18,11 +18,11 @@
   },
   "dependencies": {
     "@polkadot/types": "5.9.1",
-    "@joystream/hydra-common": "3.1.0-alpha.16",
-    "@joystream/hydra-db-utils": "3.1.0-alpha.16",
+    "@joystream/hydra-common": "^3.1.0-alpha.20",
+    "@joystream/hydra-db-utils": "^3.1.0-alpha.20",
     "@joystream/metadata-protobuf": "^2.0.0",
     "@joystream/types": "^0.18.2",
-    "@joystream/warthog": "2.41.2",
+    "@joystream/warthog": "^2.41.4",
     "@apollo/client": "^3.2.5"
   },
   "devDependencies": {

+ 75 - 0
query-node/mappings/queryTemplates.ts

@@ -0,0 +1,75 @@
+// this file will be copied to `/generated` folder; provides GraphQL query examples to GraphQL PLayground
+
+import {
+  IQueryTemplate,
+  queryTemplateUtils,
+} from '@apollographql/graphql-playground-react/lib/components/Playground/QueryTemplates/templateUtils'
+
+// fields that will be ignored by autofill
+const commonIgnoredFields = ['deletedAt', 'createdById', 'updatedById', 'deletedById', 'version']
+
+const exampleDate = `"2018-01-31 23:59"`
+
+export const queryTemplates: IQueryTemplate[] = [
+  ...queryTemplateUtils.getOneGetAllTemplates('video', 'videos', 'videos', commonIgnoredFields),
+  {
+    title: 'Featured videos',
+    description: 'Get all featured videos.',
+    ignoredFields: commonIgnoredFields,
+    query: `query {
+      ${queryTemplateUtils.descriptionMarker}
+      videos(where: { isFeatured_eq: true }) { ${queryTemplateUtils.allPropsMarker} }
+    }`,
+  },
+  {
+    title: 'All recent videos',
+    description: 'Get all videos after created or updated after the given date.',
+    ignoredFields: commonIgnoredFields,
+    query: `query {
+      ${queryTemplateUtils.descriptionMarker}
+      videos(where: {
+        createdAt_gt: ${exampleDate},
+        updatedAt_gt: ${exampleDate},
+      }) { ${queryTemplateUtils.allPropsMarker} }
+    }`,
+  },
+
+  ...queryTemplateUtils.getOneGetAllTemplates(
+    'video category',
+    'video categories',
+    'videoCategories',
+    commonIgnoredFields
+  ),
+  {
+    title: `All videos in category`,
+    description: `Get all videos associated with the given video category.`,
+    ignoredFields: commonIgnoredFields,
+    query: `query {
+      ${queryTemplateUtils.descriptionMarker}
+      videos(where: { category: { id_eq: 1 } }) { ${queryTemplateUtils.allPropsMarker} }
+    }`,
+  },
+  ...queryTemplateUtils.getOneGetAllTemplates('channel', 'channels', 'channels', commonIgnoredFields),
+  ...queryTemplateUtils.getOneGetAllTemplates(
+    'channel category',
+    'channels categories',
+    'channelCategories',
+    commonIgnoredFields
+  ),
+
+  {
+    title: `Channel's videos`,
+    description: `Get all videos associated with the given channel.`,
+    ignoredFields: commonIgnoredFields,
+    query: `query {
+      ${queryTemplateUtils.descriptionMarker}
+      videos(where: { channel: { id_eq: 1 } }) { ${queryTemplateUtils.allPropsMarker} }
+    }`,
+  },
+
+  ...queryTemplateUtils.getOneGetAllTemplates('asset', 'assets', 'storageDataObjects', commonIgnoredFields),
+  ...queryTemplateUtils.getOneGetAllTemplates('membership', 'memberships', 'memberships', commonIgnoredFields),
+
+  ...queryTemplateUtils.getOneGetAllTemplates('curator group', 'curator groups', 'curatorGroups', commonIgnoredFields),
+  ...queryTemplateUtils.getOneGetAllTemplates('worker', 'workers', 'workers', commonIgnoredFields),
+].map(queryTemplateUtils.formatQuery)

+ 1 - 1
query-node/package.json

@@ -35,7 +35,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
-    "@joystream/hydra-processor": "3.1.0-alpha.16",
+    "@joystream/hydra-processor": "^3.1.0-alpha.20",
     "@polkadot/metadata": "^4.17.1",
     "@types/bn.js": "^4.11.6",
     "bn.js": "^5.1.2",

+ 28 - 29
yarn.lock

@@ -152,9 +152,9 @@
   dependencies:
     xss "^1.0.8"
 
-"@apollographql/graphql-playground-react@https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz":
-  version "1.7.28"
-  resolved "https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz#24c9c54e14ae0ba13c894738b4b87301f5801b26"
+"@apollographql/graphql-playground-react@https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz":
+  version "1.7.29"
+  resolved "https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz#bf0bf4a72f74de156ccf2a8638e7cb617a8b41e2"
   dependencies:
     "@types/lru-cache" "^4.1.1"
     apollo-link "^1.2.13"
@@ -1987,36 +1987,36 @@
   resolved "https://registry.yarnpkg.com/@josephg/resolvable/-/resolvable-1.0.0.tgz#cd75b09cfad18cd945de9221d403203aa07e3d0a"
   integrity sha512-OfTtjoqB2doov5aTJxkyAMK8dXoo7CjCUQSYUEtiY34jbWduOGV7+168tmCT8COMsUEd5DMSFg/0iAOPCBTNAQ==
 
-"@joystream/hydra-common@3.1.0-alpha.16", "@joystream/hydra-common@^3.1.0-alpha.16":
-  version "3.1.0-alpha.16"
-  resolved "https://registry.yarnpkg.com/@joystream/hydra-common/-/hydra-common-3.1.0-alpha.16.tgz#ae9c140d863c82f7b42e9265fe644125d1ec6cf9"
-  integrity sha512-XG/UvwCBvjjftbyemWGFUzvyB+gYHCZVHtbfthZaaPnq50L+wyCnjWpiFF/PFT3I8cMwj3HT6i8G2lQPdxRVfw==
+"@joystream/hydra-common@^3.1.0-alpha.20":
+  version "3.1.0-alpha.20"
+  resolved "https://registry.yarnpkg.com/@joystream/hydra-common/-/hydra-common-3.1.0-alpha.20.tgz#5fa29183b3ee4bcbd10a5b4f355cdce74d507e3b"
+  integrity sha512-4W6ewAu0f0KF46Q7+bZL1RZIWDmuRH6PXLkAKJ6eYYdWLfbLNxVxt09mhFbee+lHERD1M30D53FX97kgQ+is9g==
   dependencies:
     bn.js "^5.1.3"
 
-"@joystream/hydra-db-utils@3.1.0-alpha.16", "@joystream/hydra-db-utils@^3.1.0-alpha.16":
-  version "3.1.0-alpha.16"
-  resolved "https://registry.yarnpkg.com/@joystream/hydra-db-utils/-/hydra-db-utils-3.1.0-alpha.16.tgz#fbed064cc47f232fb38bb48db03b82bdc357b2c9"
-  integrity sha512-4ABM4ZQ3/ZIDHe0g3u/FrPgef8wnH0dpfTnYx4qtepbr2iHHxW6b4k038Ubpuo0mvJRnnabE0+q4mPYsBGuwoQ==
+"@joystream/hydra-db-utils@^3.1.0-alpha.20":
+  version "3.1.0-alpha.20"
+  resolved "https://registry.yarnpkg.com/@joystream/hydra-db-utils/-/hydra-db-utils-3.1.0-alpha.20.tgz#9894644f9aaf371a229f4425752c221dfac2711e"
+  integrity sha512-7fmUZPxPaMDaEQBUNcIkFCKju+vdWRCeleSjJaGwtRdhBASIfIlXWcZdd2oafmUPQTVS7A2zAzdKKK1jodafWQ==
   dependencies:
-    "@joystream/hydra-common" "^3.1.0-alpha.16"
+    "@joystream/hydra-common" "^3.1.0-alpha.20"
     "@types/ioredis" "^4.17.4"
     bn.js "^5.1.3"
     ioredis "^4.17.3"
     lodash "^4.17.20"
-    shortid "^2.2.16"
     typeorm "^0.2.25"
 
-"@joystream/hydra-processor@3.1.0-alpha.16":
-  version "3.1.0-alpha.16"
-  resolved "https://registry.yarnpkg.com/@joystream/hydra-processor/-/hydra-processor-3.1.0-alpha.16.tgz#c1f5d6e879d1b39c41706b7dc41069a1e1dcd78a"
-  integrity sha512-hUzl2oR2FCvNd1/no+lX6EPdRNCSZChaAQT8lHBb296Ol/fxCmgW3Faudyrv289Zj3yQNP4EaHCrPHBhvpPG4Q==
+"@joystream/hydra-processor@^3.1.0-alpha.20":
+  version "3.1.0-alpha.20"
+  resolved "https://registry.yarnpkg.com/@joystream/hydra-processor/-/hydra-processor-3.1.0-alpha.20.tgz#e9c72e6a60fdd862805b28c9c80109e0e0bee6f3"
+  integrity sha512-YCu2knfTHUUTOsE5+rc6QKVRDPUnJj/LML0ys/FZ1QbzZeB5gM+T7zQOHlRJ9tN1Rg9f0yf6IalZBR5xgxfZyA==
   dependencies:
-    "@joystream/hydra-common" "^3.1.0-alpha.16"
-    "@joystream/hydra-db-utils" "^3.1.0-alpha.16"
+    "@joystream/hydra-common" "^3.1.0-alpha.20"
+    "@joystream/hydra-db-utils" "^3.1.0-alpha.20"
     "@oclif/command" "^1.8.0"
     "@oclif/config" "^1"
     "@oclif/errors" "^1.3.3"
+    async-lock "^1.3.1"
     bn.js "^5.2.0"
     chalk "^4.1.0"
     delay "^5.0.0"
@@ -2031,17 +2031,16 @@
     p-whilst "~2.1.0"
     prom-client "^12.0.0"
     semver "^7.3.4"
-    shortid "^2.2.16"
     typedi "^0.8.0"
     yaml "^1.10.0"
     yaml-validator "^3.0.0"
 
-"@joystream/warthog@2.41.2", "@joystream/warthog@~2.41.2":
-  version "2.41.2"
-  resolved "https://registry.yarnpkg.com/@joystream/warthog/-/warthog-2.41.2.tgz#6d3cf5c977320d1c77be518e848e011a9699b22d"
-  integrity sha512-1w6aT5P3xiI/HaTtqJrVj4Yp1/gxG8cGTeYgzlwr3iq8J11skwE4rLCHQucHfVueyBX49AaqWrhl+wI2ACqk4Q==
+"@joystream/warthog@^2.41.4":
+  version "2.41.4"
+  resolved "https://registry.yarnpkg.com/@joystream/warthog/-/warthog-2.41.4.tgz#4b0a396d9d6eee9e469a36b1ca1c86c3890d56d6"
+  integrity sha512-yfGgrjbg3alGR+7g1NcSTdlpYtgH0kDFNDSKFWiYFEPNsjwwCBgWnsVQ+ED1PWAa2RhUhwp9J4dsI5U21P543A==
   dependencies:
-    "@apollographql/graphql-playground-react" "https://github.com/Joystream/graphql-playground/releases/download/joystream%401.7.28/graphql-playground-react-v1.7.28.tgz"
+    "@apollographql/graphql-playground-react" "https://github.com/Joystream/graphql-playground/releases/download/graphql-playground-react%401.7.29/graphql-playground-react-v1.7.29.tgz"
     "@types/app-root-path" "^1.2.4"
     "@types/bn.js" "^4.11.6"
     "@types/caller" "^1.0.0"
@@ -4714,9 +4713,9 @@ aws-credstash@^3.0.0:
     debug "^4.3.1"
 
 aws-sdk@^2.567.0:
-  version "2.1078.0"
-  resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1078.0.tgz#5871750b38045f05e141e5217521f8ff8bf73a26"
-  integrity sha512-eJuiiCE4tomYzsxqfsjERmQ1WQkNAe5RUhOXUwJbGTEfwmbiQqq/HgVYrwcMswOHoURbtKpB5SSrTLNOBuyurA==
+  version "2.1083.0"
+  resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1083.0.tgz#afdc3d99d035b84b1dc75437f7670af0078ed2ab"
+  integrity sha512-o9pOC3LrkJRKLwSumdFrNWzGAVRNPGt4EFS48/917BaFafvnOAzOG/DM8cl5yguz3wT7eylj92I4pP2TE3qZIQ==
   dependencies:
     buffer "4.9.2"
     events "1.1.1"
@@ -16654,7 +16653,7 @@ shellwords@^0.1.1:
   resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
   integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
 
-shortid@^2.2.15, shortid@^2.2.16:
+shortid@^2.2.15:
   version "2.2.16"
   resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.16.tgz#b742b8f0cb96406fd391c76bfc18a67a57fe5608"
   integrity sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==