the big refactor 2: ObjID
This commit is contained in:
@@ -4,11 +4,44 @@ import "./index.scss"
|
||||
import App from "./App"
|
||||
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client"
|
||||
import "react-contexify/dist/ReactContexify.css"
|
||||
import ObjID from "./types/ObjID"
|
||||
|
||||
const client = new ApolloClient({
|
||||
uri: "/api/graphql",
|
||||
cache: new InMemoryCache({
|
||||
typePolicies:{
|
||||
File:{
|
||||
fields:{
|
||||
id:{
|
||||
merge(_,incomming){
|
||||
// HACK: i use the merge function to change the id from a string to ObjID object.
|
||||
// afaik apollo does not yet support custom scalar types.
|
||||
if (!incomming){
|
||||
return incomming
|
||||
}else if (incomming instanceof ObjID){
|
||||
return incomming
|
||||
}else{
|
||||
return ObjID.fromString(incomming as string)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Directory:{
|
||||
fields:{
|
||||
id:{
|
||||
merge(_,incomming){
|
||||
if (!incomming){
|
||||
return incomming
|
||||
}else if (incomming instanceof ObjID){
|
||||
return incomming
|
||||
}else{
|
||||
return ObjID.fromString(incomming as string)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Query: {
|
||||
fields: {
|
||||
files: {
|
||||
|
||||
Reference in New Issue
Block a user