This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apollo = new ApolloServer({ schema }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSqlmancerClient, makeSqlmancerSchema } from "sqlmancer"; | |
const schema = makeSqlmancerSchema({ typeDefs, resolvers }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
Query: { | |
customers: (root, args, ctx, info) => { | |
return Customer.findMany() | |
.resolveInfo(info) | |
.execute(); | |
}, | |
invoices: (root, args, ctx, info) => { | |
return Invoice.findMany() | |
.resolveInfo(info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { models: { Customer, Invoice } } = createSqlmancerClient(__filename, knex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSqlmancerClient } from "sqlmancer"; | |
const client = createSqlmancerClient(__filename, knex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Knex from "knex"; | |
const knex = Knex({ | |
client: "sqlite3", | |
connection: { | |
filename: "./sample.db" | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
invoices: [Invoice!]! | |
@relate(on: { from: "CustomerId", to: "CustomerId" }) | |
@many |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query @sqlmancer( | |
dialect: POSTGRES | |
transformFieldNames: PASCAL_CASE | |
) { | |
customers: [Customer!]! @where @orderBy @limit @offset | |
invoices: [Invoice!]! @many | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Customer @model( | |
table: "customers" | |
pk: "CustomerId" | |
) { | |
id: ID! @col(name: "CustomerId") | |
firstName: String! | |
lastName: String! | |
email: String! | |
invoices: [Invoice!]! | |
@relate(on: { from: "CustomerId", to: "CustomerId" }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query @sqlmancer( | |
dialect: SQLITE | |
transformFieldNames: PASCAL_CASE | |
) { | |
customers: [Customer!]! | |
} |