commit
4b50de13a7
|
@ -1,5 +1,5 @@
|
|||
overwrite: true
|
||||
schema: 'http://v2.discours.io/graphql'
|
||||
schema: 'https://testapi.discours.io'
|
||||
generates:
|
||||
src/graphql/introspec.gen.ts:
|
||||
plugins:
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { cacheExchange, CacheExchangeOpts } from '@urql/exchange-graphcache'
|
||||
// import schema from './introspec.gen'
|
||||
|
||||
// import schema from './introspec.gen'
|
||||
// NOTE: include codegened introspection schema when needed
|
||||
|
||||
// TODO: use urql-provided caching
|
||||
export const cache = cacheExchange({
|
||||
// TODO: include introspection schema when needed
|
||||
keys: {
|
||||
Shout: (data) => data.slug,
|
||||
Author: (data) => data.slug,
|
||||
|
|
30
src/graphql/client.ts
Normal file
30
src/graphql/client.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { createClient } from '@urql/core'
|
||||
import { isDev } from '../utils/config'
|
||||
|
||||
const localClient = (options) => {
|
||||
const url = 'http://localhost:8080'
|
||||
let c
|
||||
try {
|
||||
c = createClient({ ...options, url })
|
||||
console.info('[graphql] using local client')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
c = createClient(options)
|
||||
console.info(
|
||||
`[graphql] using ${options.url.replace('https://', '').replace('/graphql', '').replace('/', '')}`
|
||||
)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
export const initClient = (options) => {
|
||||
try {
|
||||
if (isDev) {
|
||||
console.info('[graphql] devmode detected')
|
||||
return localClient(options)
|
||||
} else return createClient(options)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return localClient(options)
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ export default gql`
|
|||
body
|
||||
slug
|
||||
pic
|
||||
parents
|
||||
children
|
||||
# community
|
||||
stat {
|
||||
_id: shouts
|
||||
|
|
|
@ -13,8 +13,8 @@ export default gql`
|
|||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
# viewed
|
||||
followers
|
||||
# viewed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ export default gql`
|
|||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
# viewed
|
||||
followers
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ export default gql`
|
|||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
# viewed
|
||||
followers
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ export default gql`
|
|||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
# viewed
|
||||
followers
|
||||
}
|
||||
}
|
||||
|
|
|
@ -644,10 +644,8 @@ export type Token = {
|
|||
|
||||
export type Topic = {
|
||||
body?: Maybe<Scalars['String']>
|
||||
children?: Maybe<Array<Maybe<Scalars['String']>>>
|
||||
community: Community
|
||||
oid?: Maybe<Scalars['String']>
|
||||
parents?: Maybe<Array<Maybe<Scalars['String']>>>
|
||||
pic?: Maybe<Scalars['String']>
|
||||
slug: Scalars['String']
|
||||
stat?: Maybe<TopicStat>
|
||||
|
@ -656,9 +654,7 @@ export type Topic = {
|
|||
|
||||
export type TopicInput = {
|
||||
body?: InputMaybe<Scalars['String']>
|
||||
children?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
||||
community: Scalars['String']
|
||||
parents?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
||||
pic?: InputMaybe<Scalars['String']>
|
||||
slug: Scalars['String']
|
||||
title?: InputMaybe<Scalars['String']>
|
||||
|
@ -671,7 +667,7 @@ export type TopicStat = {
|
|||
rating?: Maybe<Scalars['Int']>
|
||||
reacted: Scalars['Int']
|
||||
shouts: Scalars['Int']
|
||||
viewed: Scalars['Int']
|
||||
viewed?: Maybe<Scalars['Int']>
|
||||
}
|
||||
|
||||
export type User = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user