-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): ensure fuse directory exists (#139)
* ensure fuse directory exists * add test * lock
- Loading branch information
1 parent
1f225c5
commit fc8689b
Showing
8 changed files
with
162 additions
and
179 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,5 @@ | ||
--- | ||
'fuse': patch | ||
--- | ||
|
||
Ensure fuse directory exists |
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
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
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
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,12 @@ | ||
{ | ||
"name": "@fuse-fixtures/tada", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"devDependencies": { | ||
"@0no-co/graphqlsp": "1.3.3", | ||
"fuse": "workspace:*", | ||
"typescript": "^5.2.2", | ||
"gql.tada": "1.2.1" | ||
} | ||
} |
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,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"lib": ["ES2020"], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
"plugins": [ | ||
{ | ||
"name": "@0no-co/graphqlsp", | ||
"schema": "./schema.graphql", | ||
"tadaOutputLocation": "./fuse/introspection.ts" | ||
} | ||
], | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true | ||
} | ||
} |
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,35 @@ | ||
import { node } from 'fuse' | ||
|
||
type UserSource = { | ||
id: string | ||
name: string | ||
avatar_url: string | ||
} | ||
|
||
// "Nodes" are the core abstraction of Fuse. Each node represents | ||
// a resource/entity with multiple fields and has to define two things: | ||
// 1. load(): How to fetch from the underlying data source | ||
// 2. fields: What fields should be exposed and added for clients | ||
export const UserNode = node<UserSource>({ | ||
name: 'User', | ||
load: async (ids) => getUsers(ids), | ||
fields: (t) => ({ | ||
name: t.exposeString('name'), | ||
// rename to camel-case | ||
avatarUrl: t.exposeString('avatar_url'), | ||
// Add an additional firstName field | ||
firstName: t.string({ | ||
resolve: (user) => user.name.split(' ')[0], | ||
}), | ||
}), | ||
}) | ||
|
||
// Fake function to fetch users. In real applications, this would | ||
// talk to an underlying REST API/gRPC service/third-party API/… | ||
async function getUsers(ids: string[]): Promise<UserSource[]> { | ||
return ids.map((id) => ({ | ||
id, | ||
name: `Peter #${id}`, | ||
avatar_url: `https://i.pravatar.cc/300?u=${id}`, | ||
})) | ||
} |
Oops, something went wrong.