-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⛑️🐉 ↝ Adding YAML configuration for GraphQL interaction with #16
I've moved the main authentication function (Flask, Moralis) in the `server` directory into the `api/auth` dir. No longer appears to work (apparently an issue with `magic-sdk` not being included in another node package. We'll fix this later, but since we're getting Lens to handle the signature process for the next part of this webapp, that isn't going to be fixed for now. Signal-K/Silfur#24
- Loading branch information
1 parent
2ec4eb7
commit 95feace
Showing
18 changed files
with
7,551 additions
and
145 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 1. Schema -> Path of graphql schema | ||
schema: 'https://api.lens.dev' | ||
|
||
# 2. Documents -> Path of the graphql operations | ||
documents: './graphql/*.graphql' | ||
|
||
# 3. Output -> Where should the output be generated | ||
generates: | ||
graphql/generated.ts: | ||
plugins: | ||
- typescript | ||
- typescript-operations | ||
- typescript-react-query | ||
- fragment-matcher | ||
config: | ||
dedupeFragments: true | ||
fetcher: | ||
func: './auth-fetcher#fetcher' | ||
isReactHook: false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { TableDataCellComponent } from "react-markdown/lib/ast-to-react"; | ||
|
||
const endpoint = 'https://api.lens.dev'; | ||
|
||
export const fetcher = <TData, TVariables>( | ||
query: string, | ||
variables?: TVariables, | ||
options?: RequestInit['headers'] | ||
): (() => Promise<TData>) => { | ||
return async () => { | ||
const res = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
...options, | ||
// Add Lens auth token here | ||
}, | ||
body: JSON.stringify({ | ||
query, | ||
variables | ||
}) | ||
}) | ||
|
||
const json = await res.json() | ||
|
||
if (json.errors) { | ||
const { message } = json.errors[0] || {} | ||
throw new Error(message || 'Error…') | ||
} | ||
|
||
return json.data | ||
} | ||
} |
Oops, something went wrong.