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
| defmodule MyAppWeb.Api.Macros do | |
| @moduledoc """ | |
| Not actual Absinthe middleware. | |
| """ | |
| use Absinthe.Schema.Notation | |
| @doc """ | |
| Macro to reuse the common pattern of preloading associations using | |
| a batch function using `id` as the key. |
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 { Prisma } from "@prisma/client"; | |
| import { Buffer } from "buffer"; | |
| import _ from "lodash"; | |
| export interface CastOptions { | |
| trimStrings?: boolean; | |
| } | |
| export enum Types { | |
| Integer, |
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
| defmodule MyAppWeb.Api.Middleware.LazyPreload do | |
| @moduledoc """ | |
| Absinthe middleware to preload Ecto associations only if they have | |
| been requested. | |
| """ | |
| require Absinthe.Schema.Notation | |
| defmacro lazy_preload(assoc_name) do | |
| quote do |
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
| defmodule MyApp.Guards do | |
| defguard is_id(id) when is_binary(id) or is_integer(id) | |
| end |
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
| defmodule MyApp.Application do | |
| # See https://hexdocs.pm/elixir/Application.html | |
| # for more information on OTP Applications | |
| @moduledoc false | |
| use Application | |
| @migrator if Mix.env() in [:prod, :staging], do: [MyApp.Migrator], else: [] | |
| def start(_type, _args) do | |
| children = |
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
| defmodule MyAppWeb.Api.Middleware.RestrictAccess do | |
| @behaviour Absinthe.Middleware | |
| @moduledoc """ | |
| A simple Absinthe middleware to ensure that GraphQL queries or mutations | |
| are always run by authorized users. | |
| """ | |
| def init(default), do: default |
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
| defmodule MyAppWeb.Api.Middleware.FormatPage do | |
| @behaviour Absinthe.Middleware | |
| def call(%{value: %Scrivener.Page{} = page} = res, _) do | |
| %{ | |
| entries: data, | |
| page_number: page_number, | |
| page_size: page_size, | |
| total_pages: total_pages, | |
| total_entries: total_entries |
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
| #!/bin/sh | |
| DOWNLOAD_URL="https://download.oracle.com/otn-pub/java/jdk/8u271-b09/61ae65e088624f5aaa0b1d2d801acb16/jdk-8u271-linux-x64.tar.gz" | |
| wget -c --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" $DOWNLOAD_URL |