@omnigraph/sql 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/directives.js +59 -0
  3. package/dist/cjs/directives.js.map +7 -0
  4. package/dist/cjs/index.js +22 -0
  5. package/dist/cjs/index.js.map +7 -0
  6. package/dist/cjs/introspect/mysql.js +93 -0
  7. package/dist/cjs/introspect/postgres.js +106 -0
  8. package/dist/cjs/introspect/sqlite.js +60 -0
  9. package/dist/cjs/introspect/sqlite.js.map +7 -0
  10. package/dist/cjs/introspect/types.js +0 -0
  11. package/dist/cjs/introspect/types.js.map +7 -0
  12. package/dist/cjs/naming.js +54 -0
  13. package/dist/cjs/naming.js.map +7 -0
  14. package/dist/cjs/package.json +1 -0
  15. package/dist/cjs/schema.js +712 -0
  16. package/dist/cjs/schema.js.map +7 -0
  17. package/dist/cjs/type-map.js +40 -0
  18. package/dist/cjs/type-map.js.map +7 -0
  19. package/dist/esm/directives.js +55 -0
  20. package/dist/esm/directives.js.map +7 -0
  21. package/dist/esm/index.js +15 -0
  22. package/dist/esm/index.js.map +7 -0
  23. package/dist/esm/introspect/mysql.js +90 -0
  24. package/dist/esm/introspect/postgres.js +102 -0
  25. package/dist/esm/introspect/sqlite.js +57 -0
  26. package/dist/esm/introspect/sqlite.js.map +7 -0
  27. package/dist/esm/introspect/types.js +0 -0
  28. package/dist/esm/introspect/types.js.map +7 -0
  29. package/dist/esm/naming.js +50 -0
  30. package/dist/esm/naming.js.map +7 -0
  31. package/dist/esm/schema.js +707 -0
  32. package/dist/esm/schema.js.map +7 -0
  33. package/dist/esm/type-map.js +37 -0
  34. package/dist/esm/type-map.js.map +7 -0
  35. package/dist/package.json +54 -0
  36. package/dist/typings/directives.d.cts +17 -0
  37. package/dist/typings/directives.d.ts +17 -0
  38. package/dist/typings/index.d.cts +10 -0
  39. package/dist/typings/index.d.ts +10 -0
  40. package/dist/typings/introspect/mysql.d.cts +7 -0
  41. package/dist/typings/introspect/mysql.d.ts +7 -0
  42. package/dist/typings/introspect/postgres.d.cts +9 -0
  43. package/dist/typings/introspect/postgres.d.ts +9 -0
  44. package/dist/typings/introspect/sqlite.d.cts +8 -0
  45. package/dist/typings/introspect/sqlite.d.ts +8 -0
  46. package/dist/typings/introspect/types.d.cts +26 -0
  47. package/dist/typings/introspect/types.d.ts +26 -0
  48. package/dist/typings/naming.d.cts +17 -0
  49. package/dist/typings/naming.d.ts +17 -0
  50. package/dist/typings/schema.d.cts +39 -0
  51. package/dist/typings/schema.d.ts +39 -0
  52. package/dist/typings/type-map.d.cts +4 -0
  53. package/dist/typings/type-map.d.ts +4 -0
  54. package/package.json +61 -4
  55. package/src/directives.ts +67 -0
  56. package/src/index.ts +20 -0
  57. package/src/introspect/mysql.ts +110 -0
  58. package/src/introspect/postgres.ts +142 -0
  59. package/src/introspect/sqlite.ts +90 -0
  60. package/src/introspect/types.ts +31 -0
  61. package/src/naming.ts +67 -0
  62. package/src/schema.ts +834 -0
  63. package/src/type-map.ts +50 -0
  64. package/test/__snapshots__/sqlite-chinook.spec.ts.snap +328 -0
  65. package/test/sqlite-chinook.spec.ts +33 -0
  66. package/README.md +0 -3
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/schema.ts"],
4
+ "sourcesContent": ["import { GraphQLBoolean, GraphQLInt, GraphQLNonNull, GraphQLString } from 'graphql';\nimport { SchemaComposer } from 'graphql-compose';\nimport { GraphQLBigInt, GraphQLDate, GraphQLDateTime, GraphQLJSON } from 'graphql-scalars';\nimport { path as pathHelper } from '@graphql-mesh/cross-helpers';\nimport type { SqlDialect } from '@graphql-mesh/transport-sql';\nimport {\n SqlMutationDirective,\n SqlMutationKindEnum,\n SqlQueryDirective,\n SqlQueryKindEnum,\n SqlRelationDirective,\n TransportDirective,\n} from './directives.js';\nimport { introspectSqlite } from './introspect/sqlite.js';\nimport type { SqlColumnMeta, SqlSchemaMeta, SqlTableMeta } from './introspect/types.js';\nimport { createDefaultNaming, type SqlNaming } from './naming.js';\nimport { mapSqlTypeToGraphQL } from './type-map.js';\n\nconst FEDERATION_LINK_URL = 'https://specs.apollo.dev/federation/v2.6';\n\nexport interface LoadSqlSubgraphOpts {\n type: SqlDialect;\n /** Sqlite file path (relative to cwd or absolute) */\n db?: string;\n /** Connection URI for postgres/mysql (or sqlite file:) */\n connectionString?: string;\n cwd?: string;\n schema?: string;\n includeTables?: string[];\n excludeTables?: string[];\n naming?: Partial<SqlNaming>;\n}\n\nexport async function loadGraphQLSchemaFromSql(subgraphName: string, opts: LoadSqlSubgraphOpts) {\n const naming: SqlNaming = { ...createDefaultNaming(), ...opts.naming };\n const meta = await introspect(opts);\n const location = resolveLocation(opts);\n const schemaComposer = new SchemaComposer();\n\n schemaComposer.add(GraphQLBigInt);\n schemaComposer.add(GraphQLJSON);\n schemaComposer.add(GraphQLDate);\n schemaComposer.add(GraphQLDateTime);\n schemaComposer.addDirective(TransportDirective);\n schemaComposer.addDirective(SqlQueryDirective);\n schemaComposer.addDirective(SqlMutationDirective);\n schemaComposer.addDirective(SqlRelationDirective);\n schemaComposer.add(SqlQueryKindEnum);\n schemaComposer.add(SqlMutationKindEnum);\n\n ensureSharedFilterInputs(schemaComposer);\n ensurePageInfo(schemaComposer);\n\n const tableByName = new Map(meta.tables.map(t => [t.name, t]));\n const typeNameByTable = new Map(\n meta.tables.map(t => [t.name, naming.typeName(t.name)] as const),\n );\n\n // Pass 1: object types + column fields\n for (const table of meta.tables) {\n const typeName = typeNameByTable.get(table.name)!;\n const pkCols = table.columns.filter(c => c.primaryKey);\n const solePk = pkCols.length === 1 ? pkCols[0] : undefined;\n\n const otc = schemaComposer.createObjectTC({\n name: typeName,\n fields: {},\n });\n otc.setDirectives([\n {\n name: 'key',\n args: {\n fields: solePk\n ? naming.pkFieldName(solePk.name, true)\n : pkCols.map(c => naming.fieldName(c.name)).join(' '),\n },\n },\n ]);\n\n for (const col of table.columns) {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n const fieldName = isSolePkCol\n ? naming.pkFieldName(col.name, true)\n : naming.fieldName(col.name);\n const gqlType = mapSqlTypeToGraphQL(col.dataType, { asId: isSolePkCol });\n otc.setField(fieldName, {\n type: col.notNull || isSolePkCol ? new GraphQLNonNull(gqlType) : gqlType,\n });\n }\n\n createFilterAndOrder(schemaComposer, naming, typeName, table, solePk);\n createConnectionTypes(schemaComposer, typeName);\n createMutationInputs(schemaComposer, naming, typeName, table, solePk);\n }\n\n // Pass 2: relations\n for (const table of meta.tables) {\n const typeName = typeNameByTable.get(table.name)!;\n const otc = schemaComposer.getOTC(typeName);\n const solePk = table.columns.filter(c => c.primaryKey);\n const solePkCol = solePk.length === 1 ? solePk[0] : undefined;\n\n for (const fk of table.foreignKeys) {\n if (fk.columns.length !== 1 || fk.refColumns.length !== 1) continue;\n const refTable = tableByName.get(fk.refTable);\n if (!refTable) continue;\n const refTypeName = typeNameByTable.get(fk.refTable)!;\n const localCol = fk.columns[0];\n const refCol = fk.refColumns[0];\n const localField =\n solePkCol && localCol === solePkCol.name\n ? naming.pkFieldName(localCol, true)\n : naming.fieldName(localCol);\n const refSolePk = refTable.columns.filter(c => c.primaryKey);\n const refField =\n refSolePk.length === 1 && refCol === refSolePk[0].name\n ? naming.pkFieldName(refCol, true)\n : naming.fieldName(refCol);\n\n // belongsTo on local table\n const belongsToName = naming.singularField(refTypeName);\n if (!otc.hasField(belongsToName)) {\n otc.setField(belongsToName, {\n type: refTypeName,\n directives: [\n {\n name: 'sql__relation',\n args: {\n subgraph: subgraphName,\n table: fk.refTable,\n kind: 'ROW',\n args: `${refCol}: $this.${localField}`,\n selection: selectionBlock(naming, refTable),\n },\n },\n ],\n });\n }\n\n // hasMany on referenced table\n const refOtc = schemaComposer.getOTC(refTypeName);\n const hasManyName = naming.pluralField(typeName);\n if (!refOtc.hasField(hasManyName)) {\n refOtc.setField(hasManyName, {\n type: `[${typeName}!]!`,\n args: {\n filter: naming.filterInput(typeName),\n orderBy: `[${naming.orderByEnum(typeName)}!]`,\n limit: 'Int',\n offset: 'Int',\n },\n directives: [\n {\n name: 'sql__relation',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'ROWS',\n args: [\n `${localCol}: $this.${refField}`,\n `filter: $args.filter`,\n `orderBy: $args.orderBy`,\n `limit: $args.limit`,\n `offset: $args.offset`,\n ].join('\\n'),\n selection: selectionBlock(naming, table),\n },\n },\n ],\n });\n }\n }\n }\n\n // Pass 3: Query + Mutation roots\n const queryTC = schemaComposer.Query;\n const mutationTC = schemaComposer.Mutation;\n\n for (const table of meta.tables) {\n const typeName = typeNameByTable.get(table.name)!;\n const pkCols = table.columns.filter(c => c.primaryKey);\n const solePk = pkCols.length === 1 ? pkCols[0] : undefined;\n const selection = selectionBlock(naming, table);\n const plural = naming.pluralField(typeName);\n const singular = naming.singularField(typeName);\n\n if (solePk) {\n const pkField = naming.pkFieldName(solePk.name, true);\n queryTC.setField(singular, {\n type: typeName,\n args: {\n [pkField]: 'ID!',\n },\n directives: [\n {\n name: 'sql__query',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'ROW',\n args: `${solePk.name}: $args.${pkField}`,\n selection,\n entity: true,\n },\n },\n ],\n });\n }\n\n queryTC.setField(plural, {\n type: `[${typeName}!]!`,\n args: {\n filter: naming.filterInput(typeName),\n orderBy: `[${naming.orderByEnum(typeName)}!]`,\n limit: { type: GraphQLInt, defaultValue: 10 },\n offset: { type: GraphQLInt, defaultValue: 0 },\n },\n directives: [\n {\n name: 'sql__query',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'ROWS',\n args: [\n `filter: $args.filter`,\n `orderBy: $args.orderBy`,\n `limit: $args.limit`,\n `offset: $args.offset`,\n ].join('\\n'),\n selection,\n },\n },\n ],\n });\n\n queryTC.setField(naming.connectionField(typeName), {\n type: `${typeName}Connection!`,\n args: {\n filter: naming.filterInput(typeName),\n orderBy: `[${naming.orderByEnum(typeName)}!]`,\n first: GraphQLInt,\n after: GraphQLString,\n },\n directives: [\n {\n name: 'sql__query',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'CONNECTION',\n args: [\n `filter: $args.filter`,\n `orderBy: $args.orderBy`,\n `first: $args.first`,\n `after: $args.after`,\n ].join('\\n'),\n selection: [\n `nodes {`,\n indent(selection),\n `}`,\n `edges {`,\n ` cursor: $cursor`,\n ` node {`,\n indent(selection, 2),\n ` }`,\n `}`,\n `pageInfo {`,\n ` hasNextPage: $hasNextPage`,\n ` hasPreviousPage: $hasPreviousPage`,\n ` startCursor: $startCursor`,\n ` endCursor: $endCursor`,\n `}`,\n `totalCount: $totalCount`,\n ].join('\\n'),\n },\n },\n ],\n });\n\n queryTC.setField(naming.countField(typeName), {\n type: 'Int!',\n args: {\n filter: naming.filterInput(typeName),\n },\n directives: [\n {\n name: 'sql__query',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'COUNT',\n args: `filter: $args.filter`,\n selection: '$',\n },\n },\n ],\n });\n\n // Mutations\n const payloadKey = singular;\n mutationTC.setField(`create${typeName}`, {\n type: `${naming.payloadType(typeName)}!`,\n args: {\n input: `${naming.createInput(typeName)}!`,\n },\n directives: [\n {\n name: 'sql__mutation',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'INSERT',\n args: insertArgsBlock(naming, table, solePk),\n selection: `${payloadKey} {\\n${indent(selection)}\\n}`,\n },\n },\n ],\n });\n\n if (solePk) {\n const pkField = naming.pkFieldName(solePk.name, true);\n mutationTC.setField(`update${typeName}`, {\n type: `${naming.payloadType(typeName)}!`,\n args: {\n [pkField]: 'ID!',\n input: `${naming.updateInput(typeName)}!`,\n },\n directives: [\n {\n name: 'sql__mutation',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'UPDATE',\n args: [\n `set {`,\n indent(updateSetBlock(naming, table, solePk)),\n `}`,\n `where {`,\n ` ${solePk.name}: $args.${pkField}`,\n `}`,\n ].join('\\n'),\n selection: `${payloadKey} {\\n${indent(selection)}\\n}`,\n },\n },\n ],\n });\n\n mutationTC.setField(`delete${typeName}`, {\n type: `${naming.deletePayloadType(typeName)}!`,\n args: {\n [pkField]: 'ID!',\n },\n directives: [\n {\n name: 'sql__mutation',\n args: {\n subgraph: subgraphName,\n table: table.name,\n kind: 'DELETE',\n args: [`where {`, ` ${solePk.name}: $args.${pkField}`, `}`].join('\\n'),\n selection: [`ok: $affectedRows`, `affectedRows: $affectedRows`].join('\\n'),\n },\n },\n ],\n });\n }\n }\n\n const schema = schemaComposer.buildSchema();\n const extensions: any = (schema.extensions ||= {});\n extensions.directives ||= {};\n extensions.directives.transport = {\n subgraph: subgraphName,\n kind: 'sql',\n location,\n options: {\n dialect: opts.type,\n },\n };\n extensions.directives.link = [\n {\n url: FEDERATION_LINK_URL,\n import: ['@key'],\n },\n ];\n return schema;\n}\n\nasync function introspect(opts: LoadSqlSubgraphOpts): Promise<SqlSchemaMeta> {\n switch (opts.type) {\n case 'sqlite': {\n const db = opts.db || opts.connectionString;\n if (!db) {\n throw new Error(`loadSqlSubgraph type \"sqlite\" requires db or connectionString`);\n }\n return introspectSqlite({\n db,\n cwd: opts.cwd,\n includeTables: opts.includeTables,\n excludeTables: opts.excludeTables,\n });\n }\n case 'postgres':\n throw new Error(\n 'Postgres introspection is not implemented yet in this PR (sqlite end-to-end first).',\n );\n case 'mysql':\n throw new Error(\n 'MySQL introspection is not implemented yet in this PR (sqlite end-to-end first).',\n );\n default:\n throw new Error(`Unknown SQL loader type: ${(opts as any).type}`);\n }\n}\n\nfunction resolveLocation(opts: LoadSqlSubgraphOpts): string {\n if (opts.connectionString) return opts.connectionString;\n if (opts.db) {\n const cwd = opts.cwd || process.cwd();\n const abs = pathHelper.isAbsolute(opts.db) ? opts.db : pathHelper.join(cwd, opts.db);\n return `file:${abs}`;\n }\n throw new Error('SQL loader requires db or connectionString');\n}\n\nfunction ensureSharedFilterInputs(schemaComposer: SchemaComposer) {\n if (!schemaComposer.has('StringFilter')) {\n schemaComposer.createInputTC({\n name: 'StringFilter',\n fields: {\n eq: 'String',\n ne: 'String',\n in: '[String!]',\n nin: '[String!]',\n lt: 'String',\n lte: 'String',\n gt: 'String',\n gte: 'String',\n includes: 'String',\n startsWith: 'String',\n endsWith: 'String',\n isNull: 'Boolean',\n },\n });\n }\n if (!schemaComposer.has('IntFilter')) {\n schemaComposer.createInputTC({\n name: 'IntFilter',\n fields: {\n eq: 'Int',\n ne: 'Int',\n in: '[Int!]',\n nin: '[Int!]',\n lt: 'Int',\n lte: 'Int',\n gt: 'Int',\n gte: 'Int',\n isNull: 'Boolean',\n },\n });\n }\n}\n\nfunction ensurePageInfo(schemaComposer: SchemaComposer) {\n if (!schemaComposer.has('PageInfo')) {\n schemaComposer.createObjectTC({\n name: 'PageInfo',\n fields: {\n hasNextPage: 'Boolean!',\n hasPreviousPage: 'Boolean!',\n startCursor: 'String',\n endCursor: 'String',\n },\n });\n }\n}\n\nfunction createFilterAndOrder(\n schemaComposer: SchemaComposer,\n naming: SqlNaming,\n typeName: string,\n table: SqlTableMeta,\n solePk?: SqlColumnMeta,\n) {\n const filterFields: Record<string, string> = {\n and: `[${naming.filterInput(typeName)}!]`,\n or: `[${naming.filterInput(typeName)}!]`,\n not: naming.filterInput(typeName),\n };\n const orderValues: Record<string, { value: string }> = {};\n\n for (const col of table.columns) {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n const fieldName = isSolePkCol\n ? naming.pkFieldName(col.name, true)\n : naming.fieldName(col.name);\n const gql = mapSqlTypeToGraphQL(col.dataType, { asId: isSolePkCol });\n const filterType =\n gql === GraphQLInt || gql.name === 'Int' || gql.name === 'BigInt'\n ? 'IntFilter'\n : gql === GraphQLBoolean\n ? 'IntFilter'\n : 'StringFilter';\n filterFields[fieldName] = filterType;\n orderValues[naming.orderValue(fieldName, 'ASC')] = {\n value: naming.orderValue(fieldName, 'ASC'),\n };\n orderValues[naming.orderValue(fieldName, 'DESC')] = {\n value: naming.orderValue(fieldName, 'DESC'),\n };\n }\n\n schemaComposer.createInputTC({\n name: naming.filterInput(typeName),\n fields: filterFields,\n });\n schemaComposer.createEnumTC({\n name: naming.orderByEnum(typeName),\n values: orderValues,\n });\n}\n\nfunction createConnectionTypes(schemaComposer: SchemaComposer, typeName: string) {\n if (!schemaComposer.has(`${typeName}Edge`)) {\n schemaComposer.createObjectTC({\n name: `${typeName}Edge`,\n fields: {\n cursor: 'String!',\n node: `${typeName}!`,\n },\n });\n }\n if (!schemaComposer.has(`${typeName}Connection`)) {\n schemaComposer.createObjectTC({\n name: `${typeName}Connection`,\n fields: {\n edges: `[${typeName}Edge!]!`,\n pageInfo: 'PageInfo!',\n nodes: `[${typeName}!]!`,\n totalCount: 'Int!',\n },\n });\n }\n}\n\nfunction createMutationInputs(\n schemaComposer: SchemaComposer,\n naming: SqlNaming,\n typeName: string,\n table: SqlTableMeta,\n solePk?: SqlColumnMeta,\n) {\n const createFields: Record<string, any> = {};\n const updateFields: Record<string, any> = {};\n for (const col of table.columns) {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n if (isSolePkCol && col.autoIncrement) continue;\n const fieldName = isSolePkCol\n ? naming.pkFieldName(col.name, true)\n : naming.fieldName(col.name);\n const gqlType = mapSqlTypeToGraphQL(col.dataType, { asId: isSolePkCol });\n createFields[fieldName] = {\n type: col.notNull && !col.autoIncrement ? new GraphQLNonNull(gqlType) : gqlType,\n };\n updateFields[fieldName] = { type: gqlType };\n }\n schemaComposer.createInputTC({\n name: naming.createInput(typeName),\n fields: createFields,\n });\n schemaComposer.createInputTC({\n name: naming.updateInput(typeName),\n fields: updateFields,\n });\n const singular = naming.singularField(typeName);\n schemaComposer.createObjectTC({\n name: naming.payloadType(typeName),\n fields: {\n [singular]: typeName,\n },\n });\n schemaComposer.createObjectTC({\n name: naming.deletePayloadType(typeName),\n fields: {\n ok: 'Boolean!',\n affectedRows: 'Int!',\n },\n });\n}\n\nfunction selectionBlock(naming: SqlNaming, table: SqlTableMeta): string {\n const pkCols = table.columns.filter(c => c.primaryKey);\n const solePk = pkCols.length === 1 ? pkCols[0] : undefined;\n return table.columns\n .map(col => {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n const fieldName = isSolePkCol\n ? naming.pkFieldName(col.name, true)\n : naming.fieldName(col.name);\n return `${fieldName}: ${col.name}`;\n })\n .join('\\n');\n}\n\nfunction insertArgsBlock(\n naming: SqlNaming,\n table: SqlTableMeta,\n solePk?: SqlColumnMeta,\n): string {\n const lines: string[] = [];\n for (const col of table.columns) {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n if (isSolePkCol && col.autoIncrement) continue;\n const fieldName = isSolePkCol\n ? naming.pkFieldName(col.name, true)\n : naming.fieldName(col.name);\n lines.push(`${col.name}: $args.input.${fieldName}`);\n }\n return lines.join('\\n');\n}\n\nfunction updateSetBlock(\n naming: SqlNaming,\n table: SqlTableMeta,\n solePk?: SqlColumnMeta,\n): string {\n const lines: string[] = [];\n for (const col of table.columns) {\n const isSolePkCol = Boolean(solePk && col.name === solePk.name);\n if (isSolePkCol) continue;\n const fieldName = naming.fieldName(col.name);\n lines.push(`${col.name}: $args.input.${fieldName}`);\n }\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces = 1): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map(l => (l ? pad + l : l))\n .join('\\n');\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB,YAAY,gBAAgB,qBAAqB;AAC1E,SAAS,sBAAsB;AAC/B,SAAS,eAAe,aAAa,iBAAiB,mBAAmB;AACzE,SAAS,QAAQ,kBAAkB;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AAEjC,SAAS,2BAA2C;AACpD,SAAS,2BAA2B;AAEpC,MAAM,sBAAsB;AAe5B,eAAsB,yBAAyB,cAAsB,MAA2B;AAC9F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
+ import { GraphQLBigInt, GraphQLDate, GraphQLDateTime, GraphQLJSON } from 'graphql-scalars';
3
+ export function mapSqlTypeToGraphQL(dataType, opts) {
4
+ if (opts?.asId) {
5
+ return GraphQLID;
6
+ }
7
+ const t = dataType.toUpperCase();
8
+ if (t.includes('BOOL') || t === 'BIT') {
9
+ return GraphQLBoolean;
10
+ }
11
+ if (t.includes('INT') || t === 'SERIAL' || t === 'BIGSERIAL') {
12
+ if (t.includes('BIG') || t.includes('UNSIGNED')) {
13
+ return GraphQLBigInt;
14
+ }
15
+ return GraphQLInt;
16
+ }
17
+ if (t.includes('DOUBLE') ||
18
+ t.includes('FLOAT') ||
19
+ t.includes('REAL') ||
20
+ t.includes('NUMERIC') ||
21
+ t.includes('DECIMAL')) {
22
+ return GraphQLFloat;
23
+ }
24
+ if (t.includes('TIMESTAMP') || t.includes('DATETIME')) {
25
+ return GraphQLDateTime;
26
+ }
27
+ if (t === 'DATE') {
28
+ return GraphQLDate;
29
+ }
30
+ if (t.includes('JSON') || t.includes('JSONB')) {
31
+ return GraphQLJSON;
32
+ }
33
+ if (t.includes('BLOB') || t.includes('BINARY') || t.includes('BYTEA')) {
34
+ return GraphQLString;
35
+ }
36
+ return GraphQLString;
37
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/type-map.ts"],
4
+ "sourcesContent": ["import {\n GraphQLBoolean,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLString,\n type GraphQLScalarType,\n} from 'graphql';\nimport { GraphQLBigInt, GraphQLDate, GraphQLDateTime, GraphQLJSON } from 'graphql-scalars';\n\nexport function mapSqlTypeToGraphQL(\n dataType: string,\n opts?: { asId?: boolean },\n): GraphQLScalarType {\n if (opts?.asId) {\n return GraphQLID;\n }\n const t = dataType.toUpperCase();\n if (t.includes('BOOL') || t === 'BIT') {\n return GraphQLBoolean;\n }\n if (t.includes('INT') || t === 'SERIAL' || t === 'BIGSERIAL') {\n if (t.includes('BIG') || t.includes('UNSIGNED')) {\n return GraphQLBigInt as unknown as GraphQLScalarType;\n }\n return GraphQLInt;\n }\n if (\n t.includes('DOUBLE') ||\n t.includes('FLOAT') ||\n t.includes('REAL') ||\n t.includes('NUMERIC') ||\n t.includes('DECIMAL')\n ) {\n return GraphQLFloat;\n }\n if (t.includes('TIMESTAMP') || t.includes('DATETIME')) {\n return GraphQLDateTime as unknown as GraphQLScalarType;\n }\n if (t === 'DATE') {\n return GraphQLDate as unknown as GraphQLScalarType;\n }\n if (t.includes('JSON') || t.includes('JSONB')) {\n return GraphQLJSON as unknown as GraphQLScalarType;\n }\n if (t.includes('BLOB') || t.includes('BINARY') || t.includes('BYTEA')) {\n return GraphQLString;\n }\n return GraphQLString;\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,eAAe,aAAa,iBAAiB,mBAAmB;AAElE,SAAS,oBACd,UACA,MACmB;AACnB,MAAI,MAAM,MAAM;AACd,WAAO;AAAA,EACT;AACA,QAAM,IAAI,SAAS,YAAY;AAC/B,MAAI,EAAE,SAAS,MAAM,KAAK,MAAM,OAAO;AACrC,WAAO;AAAA,EACT;AACA,MAAI,EAAE,SAAS,KAAK,KAAK,MAAM,YAAY,MAAM,aAAa;AAC5D,QAAI,EAAE,SAAS,KAAK,KAAK,EAAE,SAAS,UAAU,GAAG;AAC/C,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACA,MACE,EAAE,SAAS,QAAQ,KACnB,EAAE,SAAS,OAAO,KAClB,EAAE,SAAS,MAAM,KACjB,EAAE,SAAS,SAAS,KACpB,EAAE,SAAS,SAAS,GACpB;AACA,WAAO;AAAA,EACT;AACA,MAAI,EAAE,SAAS,WAAW,KAAK,EAAE,SAAS,UAAU,GAAG;AACrD,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ;AAChB,WAAO;AAAA,EACT;AACA,MAAI,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,OAAO,GAAG;AAC7C,WAAO;AAAA,EACT;AACA,MAAI,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,QAAQ,KAAK,EAAE,SAAS,OAAO,GAAG;AACrE,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@omnigraph/sql",
3
+ "version": "0.1.0",
4
+ "sideEffects": false,
5
+ "peerDependencies": {
6
+ "graphql": "^16.0.0 || ^17.0.0"
7
+ },
8
+ "dependencies": {
9
+ "@graphql-mesh/cross-helpers": "^0.4.18",
10
+ "@graphql-mesh/transport-sql": "0.1.0",
11
+ "@graphql-mesh/types": "^0.107.3",
12
+ "@graphql-mesh/utils": "^0.107.3",
13
+ "@graphql-tools/utils": "^13.2.2",
14
+ "change-case": "^4.1.2",
15
+ "graphql-compose": "^9.3.0",
16
+ "graphql-scalars": "^2.0.1",
17
+ "mysql2": "^3.14.0",
18
+ "pg": "^8.23.1",
19
+ "pluralize": "^8.0.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "ardatan/graphql-mesh",
24
+ "directory": "packages/loaders/sql"
25
+ },
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=22.18.0"
29
+ },
30
+ "main": "cjs/index.js",
31
+ "module": "esm/index.js",
32
+ "typings": "typings/index.d.ts",
33
+ "typescript": {
34
+ "definition": "typings/index.d.ts"
35
+ },
36
+ "type": "module",
37
+ "exports": {
38
+ ".": {
39
+ "require": {
40
+ "types": "./typings/index.d.cts",
41
+ "default": "./cjs/index.js"
42
+ },
43
+ "import": {
44
+ "types": "./typings/index.d.ts",
45
+ "default": "./esm/index.js"
46
+ },
47
+ "default": {
48
+ "types": "./typings/index.d.ts",
49
+ "default": "./esm/index.js"
50
+ }
51
+ },
52
+ "./package.json": "./package.json"
53
+ }
54
+ }
@@ -0,0 +1,17 @@
1
+ import { GraphQLDirective, GraphQLEnumType } from 'graphql';
2
+ /**
3
+ * Single kind enum for `@sql` (reads, writes, and relation fields via `$this`).
4
+ */
5
+ export declare const SqlKindEnum: GraphQLEnumType;
6
+ /** @deprecated use SqlKindEnum */
7
+ export declare const SqlQueryKindEnum: GraphQLEnumType;
8
+ /** @deprecated use SqlKindEnum */
9
+ export declare const SqlMutationKindEnum: GraphQLEnumType;
10
+ export declare const SqlDirective: GraphQLDirective;
11
+ /** @deprecated use SqlDirective */
12
+ export declare const SqlQueryDirective: GraphQLDirective;
13
+ /** @deprecated use SqlDirective */
14
+ export declare const SqlMutationDirective: GraphQLDirective;
15
+ /** @deprecated relations also use `@sql` */
16
+ export declare const SqlRelationDirective: GraphQLDirective;
17
+ export { TransportDirective } from '@graphql-mesh/utils';
@@ -0,0 +1,17 @@
1
+ import { GraphQLDirective, GraphQLEnumType } from 'graphql';
2
+ /**
3
+ * Single kind enum for `@sql` (reads, writes, and relation fields via `$this`).
4
+ */
5
+ export declare const SqlKindEnum: GraphQLEnumType;
6
+ /** @deprecated use SqlKindEnum */
7
+ export declare const SqlQueryKindEnum: GraphQLEnumType;
8
+ /** @deprecated use SqlKindEnum */
9
+ export declare const SqlMutationKindEnum: GraphQLEnumType;
10
+ export declare const SqlDirective: GraphQLDirective;
11
+ /** @deprecated use SqlDirective */
12
+ export declare const SqlQueryDirective: GraphQLDirective;
13
+ /** @deprecated use SqlDirective */
14
+ export declare const SqlMutationDirective: GraphQLDirective;
15
+ /** @deprecated relations also use `@sql` */
16
+ export declare const SqlRelationDirective: GraphQLDirective;
17
+ export { TransportDirective } from '@graphql-mesh/utils';
@@ -0,0 +1,10 @@
1
+ import type { LoadSqlSubgraphOpts } from './schema.cjs';
2
+ export * from './directives.cjs';
3
+ export * from './naming.cjs';
4
+ export * from './schema.cjs';
5
+ export type * from './introspect/types.cjs';
6
+ export declare function loadSqlSubgraph(name: string, opts: LoadSqlSubgraphOpts): () => {
7
+ name: string;
8
+ schema$: Promise<import("graphql").GraphQLSchema>;
9
+ };
10
+ export { getSqlExecutor, wrapMysqlPoolAsSqlClient } from '@graphql-mesh/transport-sql';
@@ -0,0 +1,10 @@
1
+ import type { LoadSqlSubgraphOpts } from './schema.js';
2
+ export * from './directives.js';
3
+ export * from './naming.js';
4
+ export * from './schema.js';
5
+ export type * from './introspect/types.js';
6
+ export declare function loadSqlSubgraph(name: string, opts: LoadSqlSubgraphOpts): () => {
7
+ name: string;
8
+ schema$: Promise<import("graphql").GraphQLSchema>;
9
+ };
10
+ export { getSqlExecutor, wrapMysqlPoolAsSqlClient } from '@graphql-mesh/transport-sql';
@@ -0,0 +1,7 @@
1
+ import type { SqlSchemaMeta } from './types.cjs';
2
+ export interface IntrospectMysqlOpts {
3
+ connectionString: string;
4
+ includeTables?: string[];
5
+ excludeTables?: string[];
6
+ }
7
+ export declare function introspectMysql(opts: IntrospectMysqlOpts): Promise<SqlSchemaMeta>;
@@ -0,0 +1,7 @@
1
+ import type { SqlSchemaMeta } from './types.js';
2
+ export interface IntrospectMysqlOpts {
3
+ connectionString: string;
4
+ includeTables?: string[];
5
+ excludeTables?: string[];
6
+ }
7
+ export declare function introspectMysql(opts: IntrospectMysqlOpts): Promise<SqlSchemaMeta>;
@@ -0,0 +1,9 @@
1
+ import type { SqlSchemaMeta } from './types.cjs';
2
+ export interface IntrospectPostgresOpts {
3
+ connectionString: string;
4
+ includeTables?: string[];
5
+ excludeTables?: string[];
6
+ /** Defaults to `public` */
7
+ schema?: string;
8
+ }
9
+ export declare function introspectPostgres(opts: IntrospectPostgresOpts): Promise<SqlSchemaMeta>;
@@ -0,0 +1,9 @@
1
+ import type { SqlSchemaMeta } from './types.js';
2
+ export interface IntrospectPostgresOpts {
3
+ connectionString: string;
4
+ includeTables?: string[];
5
+ excludeTables?: string[];
6
+ /** Defaults to `public` */
7
+ schema?: string;
8
+ }
9
+ export declare function introspectPostgres(opts: IntrospectPostgresOpts): Promise<SqlSchemaMeta>;
@@ -0,0 +1,8 @@
1
+ import type { SqlSchemaMeta } from './types.cjs';
2
+ export interface IntrospectSqliteOpts {
3
+ db: string;
4
+ cwd?: string;
5
+ includeTables?: string[];
6
+ excludeTables?: string[];
7
+ }
8
+ export declare function introspectSqlite(opts: IntrospectSqliteOpts): SqlSchemaMeta;
@@ -0,0 +1,8 @@
1
+ import type { SqlSchemaMeta } from './types.js';
2
+ export interface IntrospectSqliteOpts {
3
+ db: string;
4
+ cwd?: string;
5
+ includeTables?: string[];
6
+ excludeTables?: string[];
7
+ }
8
+ export declare function introspectSqlite(opts: IntrospectSqliteOpts): SqlSchemaMeta;
@@ -0,0 +1,26 @@
1
+ import type { SqlAdapter } from '@graphql-mesh/transport-sql';
2
+ export type { SqlAdapter };
3
+ export interface SqlColumnMeta {
4
+ name: string;
5
+ dataType: string;
6
+ notNull: boolean;
7
+ primaryKey: boolean;
8
+ autoIncrement?: boolean;
9
+ }
10
+ export interface SqlForeignKeyMeta {
11
+ /** Local table column(s) */
12
+ columns: string[];
13
+ /** Referenced table */
14
+ refTable: string;
15
+ /** Referenced column(s) */
16
+ refColumns: string[];
17
+ }
18
+ export interface SqlTableMeta {
19
+ name: string;
20
+ columns: SqlColumnMeta[];
21
+ foreignKeys: SqlForeignKeyMeta[];
22
+ }
23
+ export interface SqlSchemaMeta {
24
+ adapter: SqlAdapter;
25
+ tables: SqlTableMeta[];
26
+ }
@@ -0,0 +1,26 @@
1
+ import type { SqlAdapter } from '@graphql-mesh/transport-sql';
2
+ export type { SqlAdapter };
3
+ export interface SqlColumnMeta {
4
+ name: string;
5
+ dataType: string;
6
+ notNull: boolean;
7
+ primaryKey: boolean;
8
+ autoIncrement?: boolean;
9
+ }
10
+ export interface SqlForeignKeyMeta {
11
+ /** Local table column(s) */
12
+ columns: string[];
13
+ /** Referenced table */
14
+ refTable: string;
15
+ /** Referenced column(s) */
16
+ refColumns: string[];
17
+ }
18
+ export interface SqlTableMeta {
19
+ name: string;
20
+ columns: SqlColumnMeta[];
21
+ foreignKeys: SqlForeignKeyMeta[];
22
+ }
23
+ export interface SqlSchemaMeta {
24
+ adapter: SqlAdapter;
25
+ tables: SqlTableMeta[];
26
+ }
@@ -0,0 +1,17 @@
1
+ export interface SqlNaming {
2
+ typeName(table: string): string;
3
+ fieldName(column: string): string;
4
+ pluralField(typeName: string): string;
5
+ singularField(typeName: string): string;
6
+ connectionField(typeName: string): string;
7
+ countField(typeName: string): string;
8
+ orderByEnum(typeName: string): string;
9
+ filterInput(typeName: string): string;
10
+ createInput(typeName: string): string;
11
+ updateInput(typeName: string): string;
12
+ payloadType(typeName: string): string;
13
+ deletePayloadType(typeName: string): string;
14
+ orderValue(fieldName: string, dir: 'ASC' | 'DESC'): string;
15
+ pkFieldName(column: string, isSolePk: boolean): string;
16
+ }
17
+ export declare function createDefaultNaming(): SqlNaming;
@@ -0,0 +1,17 @@
1
+ export interface SqlNaming {
2
+ typeName(table: string): string;
3
+ fieldName(column: string): string;
4
+ pluralField(typeName: string): string;
5
+ singularField(typeName: string): string;
6
+ connectionField(typeName: string): string;
7
+ countField(typeName: string): string;
8
+ orderByEnum(typeName: string): string;
9
+ filterInput(typeName: string): string;
10
+ createInput(typeName: string): string;
11
+ updateInput(typeName: string): string;
12
+ payloadType(typeName: string): string;
13
+ deletePayloadType(typeName: string): string;
14
+ orderValue(fieldName: string, dir: 'ASC' | 'DESC'): string;
15
+ pkFieldName(column: string, isSolePk: boolean): string;
16
+ }
17
+ export declare function createDefaultNaming(): SqlNaming;
@@ -0,0 +1,39 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { type SqlAdapter, type SqlTransportOptions } from '@graphql-mesh/transport-sql';
3
+ import { type SqlNaming } from './naming.cjs';
4
+ export interface LoadSqlSubgraphOpts extends Pick<SqlTransportOptions, 'max' | 'idleTimeout' | 'connectionTimeout' | 'tls'> {
5
+ /**
6
+ * Bun-style adapter override. When omitted, inferred from the connection URI
7
+ * protocol (`postgres://`, `mysql://` / `mysql2://` / `mariadb://`,
8
+ * `sqlite://` / `file:`, host-style → postgres, `*.db` → sqlite).
9
+ */
10
+ adapter?: SqlAdapter;
11
+ /**
12
+ * Connection URI / path — becomes `@transport(location)`.
13
+ * When omitted, resolved from Bun-compatible env vars (`DATABASE_URL`,
14
+ * `POSTGRES_URL` / `PGURL`, `MYSQL_URL`, `SQLITE_URL`, …) or `PG*` / `MYSQL_*` fields.
15
+ * Sqlite: `file:…`, `sqlite:…`, `:memory:`, or a `*.db` path.
16
+ * Mysql/Postgres: `mysql(2|s)://…`, `mariadb://…`, `postgres(ql)://…`, or host-style.
17
+ */
18
+ endpoint?: string;
19
+ cwd?: string;
20
+ schema?: string;
21
+ includeTables?: string[];
22
+ excludeTables?: string[];
23
+ /** Limit columns per table (legacy mysql `tableFields` shape). */
24
+ tableFields?: Array<{
25
+ table: string;
26
+ fields: string[];
27
+ }>;
28
+ naming?: Partial<SqlNaming>;
29
+ }
30
+ export declare function loadGraphQLSchemaFromSql(subgraphName: string, opts: LoadSqlSubgraphOpts): Promise<GraphQLSchema>;
31
+ /**
32
+ * Fill `endpoint` from Bun-compatible env vars when omitted.
33
+ */
34
+ export declare function resolveOptsEndpoint(opts: LoadSqlSubgraphOpts): LoadSqlSubgraphOpts;
35
+ /**
36
+ * Resolve adapter: explicit `adapter` wins; otherwise Bun-style protocol detection
37
+ * from `endpoint` (or env-resolved endpoint).
38
+ */
39
+ export declare function resolveAdapter(opts: LoadSqlSubgraphOpts): SqlAdapter;
@@ -0,0 +1,39 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { type SqlAdapter, type SqlTransportOptions } from '@graphql-mesh/transport-sql';
3
+ import { type SqlNaming } from './naming.js';
4
+ export interface LoadSqlSubgraphOpts extends Pick<SqlTransportOptions, 'max' | 'idleTimeout' | 'connectionTimeout' | 'tls'> {
5
+ /**
6
+ * Bun-style adapter override. When omitted, inferred from the connection URI
7
+ * protocol (`postgres://`, `mysql://` / `mysql2://` / `mariadb://`,
8
+ * `sqlite://` / `file:`, host-style → postgres, `*.db` → sqlite).
9
+ */
10
+ adapter?: SqlAdapter;
11
+ /**
12
+ * Connection URI / path — becomes `@transport(location)`.
13
+ * When omitted, resolved from Bun-compatible env vars (`DATABASE_URL`,
14
+ * `POSTGRES_URL` / `PGURL`, `MYSQL_URL`, `SQLITE_URL`, …) or `PG*` / `MYSQL_*` fields.
15
+ * Sqlite: `file:…`, `sqlite:…`, `:memory:`, or a `*.db` path.
16
+ * Mysql/Postgres: `mysql(2|s)://…`, `mariadb://…`, `postgres(ql)://…`, or host-style.
17
+ */
18
+ endpoint?: string;
19
+ cwd?: string;
20
+ schema?: string;
21
+ includeTables?: string[];
22
+ excludeTables?: string[];
23
+ /** Limit columns per table (legacy mysql `tableFields` shape). */
24
+ tableFields?: Array<{
25
+ table: string;
26
+ fields: string[];
27
+ }>;
28
+ naming?: Partial<SqlNaming>;
29
+ }
30
+ export declare function loadGraphQLSchemaFromSql(subgraphName: string, opts: LoadSqlSubgraphOpts): Promise<GraphQLSchema>;
31
+ /**
32
+ * Fill `endpoint` from Bun-compatible env vars when omitted.
33
+ */
34
+ export declare function resolveOptsEndpoint(opts: LoadSqlSubgraphOpts): LoadSqlSubgraphOpts;
35
+ /**
36
+ * Resolve adapter: explicit `adapter` wins; otherwise Bun-style protocol detection
37
+ * from `endpoint` (or env-resolved endpoint).
38
+ */
39
+ export declare function resolveAdapter(opts: LoadSqlSubgraphOpts): SqlAdapter;
@@ -0,0 +1,4 @@
1
+ import { type GraphQLScalarType } from 'graphql';
2
+ export declare function mapSqlTypeToGraphQL(dataType: string, opts?: {
3
+ asId?: boolean;
4
+ }): GraphQLScalarType;
@@ -0,0 +1,4 @@
1
+ import { type GraphQLScalarType } from 'graphql';
2
+ export declare function mapSqlTypeToGraphQL(dataType: string, opts?: {
3
+ asId?: boolean;
4
+ }): GraphQLScalarType;
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@omnigraph/sql",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "ardatan/graphql-mesh",
8
+ "directory": "packages/loaders/sql"
9
+ },
10
+ "license": "MIT",
11
+ "engines": {
12
+ "node": ">=22.18.0"
13
+ },
14
+ "main": "dist/cjs/index.js",
15
+ "module": "dist/esm/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "require": {
19
+ "types": "./dist/typings/index.d.cts",
20
+ "default": "./dist/cjs/index.js"
21
+ },
22
+ "import": {
23
+ "types": "./dist/typings/index.d.ts",
24
+ "default": "./dist/esm/index.js"
25
+ },
26
+ "default": {
27
+ "types": "./dist/typings/index.d.ts",
28
+ "default": "./dist/esm/index.js"
29
+ }
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "typings": "dist/typings/index.d.ts",
34
+ "peerDependencies": {
35
+ "graphql": "^16.0.0 || ^17.0.0"
36
+ },
37
+ "dependencies": {
38
+ "@graphql-mesh/cross-helpers": "^0.4.18",
39
+ "@graphql-mesh/transport-sql": "0.1.0",
40
+ "@graphql-mesh/types": "^0.107.3",
41
+ "@graphql-mesh/utils": "^0.107.3",
42
+ "@graphql-tools/utils": "^13.2.2",
43
+ "change-case": "^4.1.2",
44
+ "graphql-compose": "^9.3.0",
45
+ "graphql-scalars": "^2.0.1",
46
+ "mysql2": "^3.14.0",
47
+ "pg": "^8.23.1",
48
+ "pluralize": "^8.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/pg": "^8.15.4",
52
+ "@types/pluralize": "^0.0.33",
53
+ "graphql": "16.14.0"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "directory": "dist"
58
+ },
59
+ "sideEffects": false,
60
+ "typescript": {
61
+ "definition": "dist/typings/index.d.ts"
62
+ }
63
+ }
@@ -0,0 +1,67 @@
1
+ import {
2
+ DirectiveLocation,
3
+ GraphQLDirective,
4
+ GraphQLEnumType,
5
+ GraphQLNonNull,
6
+ GraphQLString,
7
+ } from 'graphql';
8
+
9
+ /**
10
+ * Single kind enum for `@sql` (reads, writes, and relation fields via `$this`).
11
+ */
12
+ export const SqlKindEnum = new GraphQLEnumType({
13
+ name: 'SqlKind',
14
+ values: {
15
+ ROW: { value: 'ROW' },
16
+ ROWS: { value: 'ROWS' },
17
+ CONNECTION: { value: 'CONNECTION' },
18
+ COUNT: { value: 'COUNT' },
19
+ INSERT: { value: 'INSERT' },
20
+ UPDATE: { value: 'UPDATE' },
21
+ DELETE: { value: 'DELETE' },
22
+ },
23
+ });
24
+
25
+ /** @deprecated use SqlKindEnum */
26
+ export const SqlQueryKindEnum = SqlKindEnum;
27
+ /** @deprecated use SqlKindEnum */
28
+ export const SqlMutationKindEnum = SqlKindEnum;
29
+
30
+ export const SqlDirective = new GraphQLDirective({
31
+ name: 'sql',
32
+ // FIELD: Query/Mutation/relations. OBJECT: type-level entity resolver (`$this` keys),
33
+ // same pattern as Connectors type-level `@connect`.
34
+ locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.OBJECT],
35
+ args: {
36
+ subgraph: { type: GraphQLString },
37
+ table: { type: new GraphQLNonNull(GraphQLString) },
38
+ kind: { type: new GraphQLNonNull(SqlKindEnum) },
39
+ /**
40
+ * Equality / join predicates plus Connectors-style spreads
41
+ * (`ArtistId: $this.id`, `...$args.where`).
42
+ */
43
+ where: { type: GraphQLString },
44
+ /** Order-by binder (`$args.orderBy`). */
45
+ orderBy: { type: GraphQLString },
46
+ /** Limit binder (`$args.limit`). */
47
+ limit: { type: GraphQLString },
48
+ /** Offset binder (`$args.offset`). */
49
+ offset: { type: GraphQLString },
50
+ /** CONNECTION page size (`$args.first`). */
51
+ first: { type: GraphQLString },
52
+ /** CONNECTION cursor (`$args.after`). */
53
+ after: { type: GraphQLString },
54
+ /** Column values for INSERT / UPDATE (`Title: $args.input.title`). */
55
+ set: { type: GraphQLString },
56
+ selection: { type: GraphQLString },
57
+ },
58
+ });
59
+
60
+ /** @deprecated use SqlDirective */
61
+ export const SqlQueryDirective = SqlDirective;
62
+ /** @deprecated use SqlDirective */
63
+ export const SqlMutationDirective = SqlDirective;
64
+ /** @deprecated relations also use `@sql` */
65
+ export const SqlRelationDirective = SqlDirective;
66
+
67
+ export { TransportDirective } from '@graphql-mesh/utils';
package/src/index.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { process as meshProcess } from '@graphql-mesh/cross-helpers';
2
+ import type { LoadSqlSubgraphOpts } from './schema.js';
3
+ import { loadGraphQLSchemaFromSql } from './schema.js';
4
+
5
+ export * from './directives.js';
6
+ export * from './naming.js';
7
+ export * from './schema.js';
8
+ export type * from './introspect/types.js';
9
+
10
+ export function loadSqlSubgraph(name: string, opts: LoadSqlSubgraphOpts) {
11
+ return () => ({
12
+ name,
13
+ schema$: loadGraphQLSchemaFromSql(name, {
14
+ ...opts,
15
+ cwd: opts.cwd || meshProcess.cwd(),
16
+ }),
17
+ });
18
+ }
19
+
20
+ export { getSqlExecutor, wrapMysqlPoolAsSqlClient } from '@graphql-mesh/transport-sql';