-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:a-type/biscuits
- Loading branch information
Showing
16 changed files
with
2,224 additions
and
3,777 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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import v34Schema, { | ||
MigrationTypes as V34Types, | ||
MigrationTypes as V34Types, | ||
} from '../client/schemaVersions/v34.js'; | ||
import { createMigration } from '@verdant-web/store'; | ||
import { createMinimalGraphQLClient, graphql } from '@biscuits/client'; | ||
import { createMinimalGraphQLClient, graphql } from '@biscuits/graphql'; | ||
import { API_HOST_HTTP } from '../config.js'; | ||
|
||
export default createMigration<V34Types>(v34Schema, async ({ mutations }) => { | ||
await mutations.collaborationInfo.put({}); | ||
try { | ||
const client = createMinimalGraphQLClient({ | ||
origin: API_HOST_HTTP, | ||
}); | ||
const result = await client.query({ | ||
query: graphql(` | ||
query DefaultCategories { | ||
foodCategories { | ||
id | ||
name | ||
sortKey | ||
} | ||
} | ||
`), | ||
}); | ||
if (!result.data) { | ||
if (result.error) throw result.error; | ||
throw new Error('No data returned'); | ||
} | ||
for (const defaultCategory of result.data.foodCategories) { | ||
await mutations.categories.put({ | ||
id: defaultCategory.id.toString(), | ||
name: defaultCategory.name, | ||
sortKey: defaultCategory.sortKey, | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
await mutations.collaborationInfo.put({}); | ||
try { | ||
const client = createMinimalGraphQLClient({ | ||
origin: API_HOST_HTTP, | ||
}); | ||
const result = await client.query({ | ||
query: graphql(` | ||
query DefaultCategories { | ||
foodCategories { | ||
id | ||
name | ||
sortKey | ||
} | ||
} | ||
`), | ||
}); | ||
if (!result.data) { | ||
if (result.error) throw result.error; | ||
throw new Error('No data returned'); | ||
} | ||
for (const defaultCategory of result.data.foodCategories) { | ||
await mutations.categories.put({ | ||
id: defaultCategory.id.toString(), | ||
name: defaultCategory.name, | ||
sortKey: defaultCategory.sortKey, | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,45 +1,45 @@ | ||
import v4Schema, { | ||
MigrationTypes as V4Types, | ||
MigrationTypes as V4Types, | ||
} from '../client/schemaVersions/v4.js'; | ||
import v5Schema, { | ||
MigrationTypes as V5Types, | ||
MigrationTypes as V5Types, | ||
} from '../client/schemaVersions/v5.js'; | ||
import { createMigration } from '@verdant-web/store'; | ||
import { createMinimalGraphQLClient, graphql } from '@biscuits/client'; | ||
import { createMinimalGraphQLClient, graphql } from '@biscuits/graphql'; | ||
import { API_HOST_HTTP } from '../config.js'; | ||
|
||
export default createMigration<V4Types, V5Types>( | ||
v4Schema, | ||
v5Schema, | ||
async ({ mutations }) => { | ||
try { | ||
const client = createMinimalGraphQLClient({ | ||
origin: API_HOST_HTTP, | ||
}); | ||
const result = await client.query({ | ||
query: graphql(` | ||
query DefaultCategories { | ||
foodCategories { | ||
id | ||
name | ||
sortKey | ||
} | ||
} | ||
`), | ||
}); | ||
if (!result.data) { | ||
if (result.error) throw result.error; | ||
throw new Error('No data returned'); | ||
} | ||
for (const defaultCategory of result.data.foodCategories) { | ||
await mutations.categories.put({ | ||
id: defaultCategory.id.toString(), | ||
name: defaultCategory.name, | ||
sortKey: defaultCategory.sortKey, | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, | ||
v4Schema, | ||
v5Schema, | ||
async ({ mutations }) => { | ||
try { | ||
const client = createMinimalGraphQLClient({ | ||
origin: API_HOST_HTTP, | ||
}); | ||
const result = await client.query({ | ||
query: graphql(` | ||
query DefaultCategories { | ||
foodCategories { | ||
id | ||
name | ||
sortKey | ||
} | ||
} | ||
`), | ||
}); | ||
if (!result.data) { | ||
if (result.error) throw result.error; | ||
throw new Error('No data returned'); | ||
} | ||
for (const defaultCategory of result.data.foodCategories) { | ||
await mutations.categories.put({ | ||
id: defaultCategory.id.toString(), | ||
name: defaultCategory.name, | ||
sortKey: defaultCategory.sortKey, | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, | ||
); |
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
Oops, something went wrong.