From fd534bfae782020e191ff4f8ec53bff907ce08a8 Mon Sep 17 00:00:00 2001 From: Samuel Andert Date: Wed, 6 Sep 2023 20:01:39 +0200 Subject: [PATCH] Added basic bookmarks --- .wundergraph/operations/getBookmarks.graphql | 8 ++ .wundergraph/schemas/directus.graphql | 107 +++++++++++++++++++ .wundergraph/wundergraph.config.ts | 1 - src/routes/me/+layout.svelte | 1 + src/routes/me/bookmarks/+page.svelte | 40 +++++++ 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 .wundergraph/operations/getBookmarks.graphql create mode 100644 src/routes/me/bookmarks/+page.svelte diff --git a/.wundergraph/operations/getBookmarks.graphql b/.wundergraph/operations/getBookmarks.graphql new file mode 100644 index 0000000..28f72c4 --- /dev/null +++ b/.wundergraph/operations/getBookmarks.graphql @@ -0,0 +1,8 @@ +query Bookmarks { + directus_bookmarks { + id + name + url + tags + } +} diff --git a/.wundergraph/schemas/directus.graphql b/.wundergraph/schemas/directus.graphql index adf4f8c..53ea6da 100644 --- a/.wundergraph/schemas/directus.graphql +++ b/.wundergraph/schemas/directus.graphql @@ -5,6 +5,9 @@ type Query { todos(filter: todos_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [todos!]! todos_by_id(id: ID!): todos todos_aggregated(groupBy: [String], filter: todos_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [todos_aggregated!]! + bookmarks(filter: bookmarks_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [bookmarks!]! + bookmarks_by_id(id: ID!): bookmarks + bookmarks_aggregated(groupBy: [String], filter: bookmarks_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [bookmarks_aggregated!]! } type Mutation { @@ -12,16 +15,23 @@ type Mutation { create_projects_item(data: create_projects_input!): projects create_todos_items(filter: todos_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, data: [create_todos_input!]): [todos!]! create_todos_item(data: create_todos_input!): todos + create_bookmarks_items(filter: bookmarks_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, data: [create_bookmarks_input!]): [bookmarks!]! + create_bookmarks_item(data: create_bookmarks_input!): bookmarks update_projects_items(filter: projects_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, ids: [ID]!, data: update_projects_input!): [projects!]! update_projects_batch(filter: projects_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, data: [update_projects_input!]): [projects!]! update_projects_item(id: ID!, data: update_projects_input!): projects update_todos_items(filter: todos_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, ids: [ID]!, data: update_todos_input!): [todos!]! update_todos_batch(filter: todos_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, data: [update_todos_input!]): [todos!]! update_todos_item(id: ID!, data: update_todos_input!): todos + update_bookmarks_items(filter: bookmarks_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, ids: [ID]!, data: update_bookmarks_input!): [bookmarks!]! + update_bookmarks_batch(filter: bookmarks_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String, data: [update_bookmarks_input!]): [bookmarks!]! + update_bookmarks_item(id: ID!, data: update_bookmarks_input!): bookmarks delete_projects_items(ids: [ID]!): delete_many delete_projects_item(id: ID!): delete_one delete_todos_items(ids: [ID]!): delete_many delete_todos_item(id: ID!): delete_one + delete_bookmarks_items(ids: [ID]!): delete_many + delete_bookmarks_item(id: ID!): delete_one } type Subscription { @@ -44,6 +54,7 @@ type Subscription { directus_users_mutated(event: EventEnum): directus_users_mutated directus_shares_mutated(event: EventEnum): directus_shares_mutated directus_webhooks_mutated(event: EventEnum): directus_webhooks_mutated + bookmarks_mutated(event: EventEnum): bookmarks_mutated } """The `Boolean` scalar type represents `true` or `false`.""" @@ -92,6 +103,58 @@ enum EventEnum { delete } +type bookmarks { + id: ID! + status: String + sort: Int + user_created(filter: directus_users_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): directus_users + date_created: Date + date_created_func: datetime_functions + user_updated(filter: directus_users_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): directus_users + date_updated: Date + date_updated_func: datetime_functions + url: String + name: String + tags: JSON + tags_func: count_functions +} + +type bookmarks_aggregated { + group: JSON + countAll: Int + count: bookmarks_aggregated_count + countDistinct: bookmarks_aggregated_count + avg: bookmarks_aggregated_fields + sum: bookmarks_aggregated_fields + avgDistinct: bookmarks_aggregated_fields + sumDistinct: bookmarks_aggregated_fields + min: bookmarks_aggregated_fields + max: bookmarks_aggregated_fields +} + +type bookmarks_aggregated_count { + id: Int + status: Int + sort: Int + user_created: Int + date_created: Int + user_updated: Int + date_updated: Int + url: Int + name: Int + tags: Int +} + +type bookmarks_aggregated_fields { + sort: Float +} + +type bookmarks_mutated { + key: ID! + event: EventEnum + data: bookmarks +} + type count_functions { count: Int } @@ -602,6 +665,24 @@ type todos_mutated { data: todos } +input bookmarks_filter { + id: string_filter_operators + status: string_filter_operators + sort: number_filter_operators + user_created: directus_users_filter + date_created: date_filter_operators + date_created_func: datetime_function_filter_operators + user_updated: directus_users_filter + date_updated: date_filter_operators + date_updated_func: datetime_function_filter_operators + url: string_filter_operators + name: string_filter_operators + tags: string_filter_operators + tags_func: count_function_filter_operators + _and: [bookmarks_filter] + _or: [bookmarks_filter] +} + input boolean_filter_operators { _eq: Boolean _neq: Boolean @@ -613,6 +694,19 @@ input count_function_filter_operators { count: number_filter_operators } +input create_bookmarks_input { + id: ID + status: String + sort: Int + user_created: create_directus_users_input + date_created: Date + user_updated: create_directus_users_input + date_updated: Date + url: String + name: String + tags: JSON +} + input create_directus_files_input { id: ID storage: String! @@ -992,6 +1086,19 @@ input todos_filter { _or: [todos_filter] } +input update_bookmarks_input { + id: ID + status: String + sort: Int + user_created: update_directus_users_input + date_created: Date + user_updated: update_directus_users_input + date_updated: Date + url: String + name: String + tags: JSON +} + input update_directus_files_input { id: ID storage: String diff --git a/.wundergraph/wundergraph.config.ts b/.wundergraph/wundergraph.config.ts index 4e13448..ee496ed 100644 --- a/.wundergraph/wundergraph.config.ts +++ b/.wundergraph/wundergraph.config.ts @@ -4,7 +4,6 @@ import operations from './wundergraph.operations'; import fs from 'fs'; import path from 'path'; import dotenv from 'dotenv'; -import axios from 'axios'; dotenv.config(); const directusSchema = fs.readFileSync(path.join(path.resolve(), './schemas/directus.graphql'), 'utf8'); diff --git a/src/routes/me/+layout.svelte b/src/routes/me/+layout.svelte index 5d2470f..f77a3e6 100644 --- a/src/routes/me/+layout.svelte +++ b/src/routes/me/+layout.svelte @@ -6,6 +6,7 @@
  • Dashboard
  • My Projects
  • Banking
  • +
  • Bookmarks
  • Access Control
  • diff --git a/src/routes/me/bookmarks/+page.svelte b/src/routes/me/bookmarks/+page.svelte new file mode 100644 index 0000000..8eb60d2 --- /dev/null +++ b/src/routes/me/bookmarks/+page.svelte @@ -0,0 +1,40 @@ + + + +
    +

    Bookmarks

    +
    + +
    +
    +
    + {#if $bookmarksQuery.isLoading} +

    Loading...

    + {:else if $bookmarksQuery.error} +
    Error: {JSON.stringify($bookmarksQuery.error, null, 2)}
    + {:else} + {#each $bookmarksQuery.data.directus_bookmarks as bookmark (bookmark.id)} + + {bookmark.name} + +
    + {#each bookmark.tags as tag (tag)} + {tag} + {/each} +
    + {/each} + {/if} +
    +
    +
    +