diff --git a/packages/backend-common/src/gql.ts b/packages/backend-common/src/gql.ts new file mode 100644 index 0000000000..ca6b9c7f55 --- /dev/null +++ b/packages/backend-common/src/gql.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const gql = (s: TemplateStringsArray, ...args: any[]) => + s.map((ss, i) => `${ss}${args[i] || ''}`).join(''); diff --git a/packages/backend-common/src/index.ts b/packages/backend-common/src/index.ts index f499613851..007e762ca9 100644 --- a/packages/backend-common/src/index.ts +++ b/packages/backend-common/src/index.ts @@ -21,3 +21,4 @@ export * from './logging'; export * from './middleware'; export * from './service'; export * from './hot'; +export * from './gql'; diff --git a/plugins/catalog-graphql/src/schema.js b/plugins/catalog-graphql/src/schema.js new file mode 100644 index 0000000000..473aad97f5 --- /dev/null +++ b/plugins/catalog-graphql/src/schema.js @@ -0,0 +1,87 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const EntityMetadataFields = /* GraphQL */ ` + name: String! + annotations: JSONObject! + annotation(name: String!): JSON + labels: JSONObject! + label(name: String!): JSON + uid: String! + etag: String! + generation: Int! +`; + +const EntityMetadata = /* GraphQL */ ` + scalar JSON + scalar JSONObject + + interface EntityMetadata { + ${EntityMetadataFields} + } + + type DefaultEntityMetadata implements EntityMetadata { + ${EntityMetadataFields} + } + + type ComponentMetadata implements EntityMetadata { + ${EntityMetadataFields} + # mock field to prove extensions working + relationships: String + } + + type TemplateMetadata implements EntityMetadata { + ${EntityMetadataFields} + # mock field to prove extensions working + updatedBy: String + } + + type TemplateEntitySpec { + type: String! + path: String + schema: JSONObject! + templater: String! + } + + type ComponentEntitySpec { + type: String! + lifecycle: String! + owner: String! + } + + type DefaultEntitySpec { + raw: JSONObject + } + + union EntitySpec = DefaultEntitySpec | TemplateEntitySpec | ComponentEntitySpec + + type CatalogEntity { + apiVersion: String! + kind: String! + metadata: EntityMetadata + spec: EntitySpec! + } + + type CatalogQuery { + list: [CatalogEntity!]! + } + + type Query { + catalog: CatalogQuery! + } +`; + +module.exports = EntityMetadata; diff --git a/yarn.lock b/yarn.lock index 2d3205f23a..58084fb145 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4611,7 +4611,7 @@ "@types/qs" "*" "@types/range-parser" "*" -"@types/express@*", "@types/express@^4.17.6", "@types/express@^4.17.7": +"@types/express@*", "@types/express@4.17.7", "@types/express@^4.17.6": version "4.17.7" resolved "https://registry.npmjs.org/@types/express/-/express-4.17.7.tgz#42045be6475636d9801369cd4418ef65cdb0dd59" integrity sha512-dCOT5lcmV/uC2J9k0rPafATeeyz+99xTt54ReX11/LObZgfzJqZNcW27zGhYyX+9iSEGXGt5qLPwRSvBZcLvtQ== @@ -11997,11 +11997,6 @@ graphql-tools@^4.0.0: iterall "^1.1.3" uuid "^3.1.0" -graphql-type-json@^0.3.2: - version "0.3.2" - resolved "https://registry.npmjs.org/graphql-type-json/-/graphql-type-json-0.3.2.tgz#f53a851dbfe07bd1c8157d24150064baab41e115" - integrity sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg== - graphql-upload@^8.0.2: version "8.1.0" resolved "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.1.0.tgz#6d0ab662db5677a68bfb1f2c870ab2544c14939a" @@ -14404,25 +14399,6 @@ jsonpointer@^4.0.1: resolved "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= -<<<<<<< HEAD -======= -jsonwebtoken@^8.1.0: - version "8.5.1" - resolved "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" - integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== - dependencies: - jws "^3.2.2" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" - ms "^2.1.1" - semver "^5.6.0" - ->>>>>>> feat(gql/catlaog): Tidying up the resolver for the annotations jspdf-autotable@3.5.3: version "3.5.3" resolved "https://registry.npmjs.org/jspdf-autotable/-/jspdf-autotable-3.5.3.tgz#2f73adb07f340e7dbf22950e3e6c8bf853991479" @@ -17126,11 +17102,7 @@ parse-entities@^2.0.0: is-decimal "^1.0.0" is-hexadecimal "^1.0.0" -<<<<<<< HEAD parse-filepath@^1.0.1: -======= -parse-filepath@1.0.2, parse-filepath@^1.0.1: ->>>>>>> feat(gql/catlaog): Tidying up the resolver for the annotations version "1.0.2" resolved "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891" integrity sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE= @@ -18212,43 +18184,12 @@ pretty-hrtime@^1.0.3: resolved "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= -<<<<<<< HEAD prismjs@^1.17.1: version "1.21.0" resolved "https://registry.npmjs.org/prismjs/-/prismjs-1.21.0.tgz#36c086ec36b45319ec4218ee164c110f9fc015a3" integrity sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw== optionalDependencies: clipboard "^2.0.0" -======= -prisma-json-schema@0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/prisma-json-schema/-/prisma-json-schema-0.1.3.tgz#6c302db8f464f8b92e8694d3f7dd3f41ac9afcbe" - integrity sha512-XZrf2080oR81mY8/OC8al68HiwBm0nXlFE727JIia0ZbNqwuV4MyRYk6E0+OIa6/9KEYxZrcAmoBs3EW1cCvnA== - -prisma-yml@1.34.10: - version "1.34.10" - resolved "https://registry.npmjs.org/prisma-yml/-/prisma-yml-1.34.10.tgz#0ef1ad3a125f54f200289cba56bdd9597f17f410" - integrity sha512-N9on+Cf/XQKFGUULk/681tnpfqiZ19UBTurFMm+/9rnml37mteDaFr2k8yz+K8Gt2xpEJ7kBu7ikG5PrXI1uoA== - dependencies: - ajv "5" - bluebird "^3.5.1" - chalk "^2.3.0" - debug "^3.1.0" - dotenv "^4.0.0" - fs-extra "^7.0.0" - graphql-request "^1.5.0" - http-proxy-agent "^2.1.0" - https-proxy-agent "^2.2.1" - isomorphic-fetch "^2.2.1" - js-yaml "^3.10.0" - json-stable-stringify "^1.0.1" - jsonwebtoken "^8.1.0" - lodash "^4.17.4" - prisma-json-schema "0.1.3" - replaceall "^0.1.6" - scuid "^1.0.2" - yaml-ast-parser "^0.0.40" ->>>>>>> feat(gql/catlaog): Tidying up the resolver for the annotations prismjs@^1.20.0, prismjs@^1.8.4, prismjs@~1.20.0: version "1.20.0" @@ -19436,11 +19377,6 @@ redux@^4.0.4, redux@^4.0.5: loose-envify "^1.4.0" symbol-observable "^1.2.0" -reflect-metadata@^0.1.13: - version "0.1.13" - resolved "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08" - integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg== - refractor@^2.4.1: version "2.10.1" resolved "https://registry.npmjs.org/refractor/-/refractor-2.10.1.tgz#166c32f114ed16fd96190ad21d5193d3afc7d34e" @@ -19665,11 +19601,7 @@ request-promise-native@^1.0.5, request-promise-native@^1.0.8: stealthy-require "^1.1.1" tough-cookie "^2.3.3" -<<<<<<< HEAD request@^2.53.0, request@^2.55.0, request@^2.85.0, request@^2.87.0, request@^2.88.0, request@^2.88.2: -======= -request@2.88.2, request@^2.55.0, request@^2.85.0, request@^2.87.0, request@^2.88.0, request@^2.88.2: ->>>>>>> feat(gql/catlaog): Tidying up the resolver for the annotations version "2.88.2" resolved "https://registry.npmjs.org/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== @@ -23083,7 +23015,6 @@ whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0, whatwg-mimetype@^2.3.0: resolved "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== -<<<<<<< HEAD whatwg-url@^2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-2.0.1.tgz#5396b2043f020ee6f704d9c45ea8519e724de659" @@ -23092,8 +23023,6 @@ whatwg-url@^2.0.1: tr46 "~0.0.3" webidl-conversions "^3.0.0" -======= ->>>>>>> chore(gql): fixing build issues whatwg-url@^6.4.1: version "6.5.0" resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"