Skip to content

Commit

Permalink
feat: graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed May 18, 2024
1 parent 31fa760 commit 427cab2
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .graphqlrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
projects:
default:
schema:
- ./apps/frontend/schema.graphql
- ./apps/frontend/$houdini/graphql/schema.graphql
documents:
- "**/*.gql"
- "**/*.svelte"
- ./apps.frontend/$houdini/graphql/documents.gql
9 changes: 0 additions & 9 deletions apps/frontend/.graphqlrc.yaml

This file was deleted.

27 changes: 27 additions & 0 deletions apps/frontend/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
type Field {
id: ID!
name: String!
type: FieldType!
}

enum FieldType {
autoIncrement
createdAt
id
number
string
updatedAt
}

type Query {
table(id: ID!): Table
tables: [Table]
Expand All @@ -7,4 +22,16 @@ type Table {
id: ID!
name: String!
recordsCount: Int!
schema: [Field!]!
views: [View!]!
}

type View {
id: ID!
name: String!
type: ViewType!
}

enum ViewType {
grid
}
16 changes: 16 additions & 0 deletions apps/frontend/src/routes/(authed)/t/[tableId]/+layout.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
query GetTableQuery($tableId: ID!) {
table(id: $tableId) {
id
name
schema {
id
name
type
}
views {
id
name
type
}
}
}
2 changes: 2 additions & 0 deletions apps/frontend/src/routes/(authed)/t/[tableId]/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GetTableQueryStore } from "$houdini"
import { trpc } from "$lib/trpc/client"
import { tableCreator } from "@undb/table"
import { superValidate } from "sveltekit-superforms"
Expand All @@ -18,6 +19,7 @@ export const load: LayoutLoad = async (event) => {

return {
table,
t: await new GetTableQueryStore().fetch({ event, variables: { tableId } }),
createRecord,
}
}
29 changes: 29 additions & 0 deletions packages/graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,36 @@ export class Graphql {
public get yoga() {
return yoga({
typeDefs: `
enum FieldType {
string
number
id
createdAt
updatedAt
autoIncrement
}
type Field {
id: ID!
name: String!
type: FieldType!
}
enum ViewType {
grid
}
type View {
id: ID!
name: String!
type: ViewType!
}
type Table {
id: ID!
name: String!
schema: [Field!]!
views: [View!]!
recordsCount: Int!
}
Expand All @@ -36,9 +63,11 @@ export class Graphql {
},
},
Table: {
// @ts-ignore
recordsCount: (table) => 100,
},
},
batching: true,
})
}
}
Expand Down

0 comments on commit 427cab2

Please sign in to comment.