This commit is contained in:
Mayel de Borniol 2021-11-24 23:25:06 +13:00
parent fd119f72bb
commit b79f56b12f
4 changed files with 35 additions and 9 deletions

View file

@ -164,6 +164,8 @@ update.fork~%: ## Pull the latest commits from all ./forks
deps.get: mix.remote~deps.get mix~deps.get js.ext.deps.get ## Fetch locked version of non-forked deps
deps.data.clean: mix~bonfire.deps.clean
#### DEPENDENCY & EXTENSION RELATED COMMANDS ####
js.deps.get: js.assets.deps.get js.ext.deps.get

View file

@ -171,6 +171,7 @@ config :bonfire_data_identity, Self, []
config :bonfire_data_identity, User,
has_one: [accounted: {Accounted, foreign_key: :id}],
# has_many: [account: {[through: [:accounted, :account]]}], # this is private info, do not expose
has_one: [profile: {Profile, foreign_key: :id}],
has_one: [character: {Character, foreign_key: :id}],
has_one: [actor: {Actor, foreign_key: :id}],
@ -180,8 +181,11 @@ config :bonfire_data_identity, User,
has_one: [peered: {Peered, references: :id, foreign_key: :id}],
has_many: [encircles: {Encircle, foreign_key: :subject_id}],
has_one: [shared_user: {Bonfire.Data.SharedUser, foreign_key: :id}],
many_to_many: [caretaker_accounts: {Account, join_through: "bonfire_data_shared_user_accounts", join_keys: [shared_user_id: :id, account_id: :id]}]
many_to_many: [caretaker_accounts: {Account, join_through: "bonfire_data_shared_user_accounts", join_keys: [shared_user_id: :id, account_id: :id]}],
# has_one: [geolocation: {Bonfire.Geolocate.Geolocation}]
has_many: [created: {Created, foreign_key: :creator_id}],
has_many: [creations: {[through: [:created, :pointer]]}],
has_many: [posts: {[through: [:created, :post]]}]
# bonfire_data_social
@ -319,7 +323,8 @@ config :bonfire_data_social, Created,
has_one: [peered: {Peered, references: :id, foreign_key: :id}],
belongs_to: [creator_user: {User, foreign_key: :creator_id, define_field: false}],
belongs_to: [creator_character: {Character, foreign_key: :creator_id, define_field: false}],
belongs_to: [creator_profile: {Profile, foreign_key: :creator_id, define_field: false}]
belongs_to: [creator_profile: {Profile, foreign_key: :creator_id, define_field: false}],
has_one: [post: {Post, references: :id, foreign_key: :id}]
config :bonfire_data_social, Profile,
belongs_to: [user: {User, foreign_key: :id, define_field: false}],

View file

@ -9,10 +9,29 @@ defmodule Bonfire.GraphQL.Schema do
require Logger
alias Bonfire.GraphQL.SchemaUtils
alias Bonfire.GraphQL.Middleware.CollapseErrors
alias Absinthe.Middleware.{Async, Batch}
@doc """
Define dataloaders
see https://hexdocs.pm/absinthe/1.4.6/ecto.html#dataloader
"""
def context(ctx) do
loader =
Dataloader.new
|> Dataloader.add_source(Bonfire.Data.Identity.User, Bonfire.Common.Pointers.dataloader())
|> Dataloader.add_source(Bonfire.Data.Social.Posts, Bonfire.Common.Pointers.dataloader())
# |> Dataloader.add_source(Foo, Foo.data())
def plugins, do: [Async, Batch]
Map.put(ctx, :loader, loader)
end
def plugins do
[
Absinthe.Middleware.Async,
Absinthe.Middleware.Batch,
Absinthe.Middleware.Dataloader
]
++ Absinthe.Plugin.defaults()
end
def middleware(middleware, _field, _object) do
# [{Bonfire.GraphQL.Middleware.Debug, :start}] ++
@ -24,14 +43,11 @@ defmodule Bonfire.GraphQL.Schema do
import_types(Bonfire.GraphQL.CommonSchema)
# import_types(CommonsPub.Web.GraphQL.MiscSchema)
# Extension Modules
# import_types(CommonsPub.Profiles.GraphQL.Schema)
# import_types(CommonsPub.Characters.GraphQL.Schema)
# import_types(Organisation.GraphQL.Schema)
import_types(Bonfire.Me.API.GraphQL)
import_types(Bonfire.Social.API.GraphQL)
# import_types(CommonsPub.Locales.GraphQL.Schema)
@ -51,6 +67,8 @@ defmodule Bonfire.GraphQL.Schema do
import_fields(:common_queries)
# Extension Modules
import_fields(:me_queries)
import_fields(:social_queries)
# import_fields(:profile_queries)
# import_fields(:character_queries)

View file

@ -49,6 +49,7 @@
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
"dataloader": {:hex, :dataloader, "1.0.9", "8fb981e327fa692f741ab283ed93790203a6f6d412800f0f4f1531372e1dbf15", [:mix], [{:ecto, ">= 3.4.3 and < 4.0.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6f8b7566c8dda46f53bdb336fd02f03f00bf58aeb6cc0f139ccdfd6f99d265a7"},
"db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"earmark": {:hex, :earmark, "1.4.16", "2188754e590a3c379fdd2783bb44eedd8c54968fa0256b6f336f6d56b089d793", [:mix], [{:earmark_parser, ">= 1.4.16", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "46f853f7ae10bee06923430dca522ba9dcbdc6b7a9729748e8dd5344d21b8418"},