diff --git a/.changeset/flat-masks-tap.md b/.changeset/flat-masks-tap.md new file mode 100644 index 0000000000..c54e761eb7 --- /dev/null +++ b/.changeset/flat-masks-tap.md @@ -0,0 +1,5 @@ +--- +'create-houdini': patch +--- + +improve template for projects with local schemas diff --git a/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts b/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts index f624d906ce..9875af5e66 100644 --- a/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts +++ b/packages/create-houdini/fragments/localSchema/react-typescript/src/api/+schema.ts @@ -8,7 +8,7 @@ export default createSchema({ `, resolvers: { Query: { - hello: () => 'world', + hello: () => 'Greetings from your local api 👋', }, }, }) diff --git a/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.gql b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.gql new file mode 100644 index 0000000000..210dadf14f --- /dev/null +++ b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.gql @@ -0,0 +1,3 @@ +query HelloHoudini { + hello +} diff --git a/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx new file mode 100644 index 0000000000..356a706682 --- /dev/null +++ b/packages/create-houdini/fragments/localSchema/react-typescript/src/routes/+page.tsx @@ -0,0 +1,11 @@ +import { PageProps } from './$types' + +export default function ({ Hello }: PageProps) { + return ( +
+

Home

+ +

{Hello.message}

+
+ ) +} diff --git a/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js b/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js index f624d906ce..9875af5e66 100644 --- a/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js +++ b/packages/create-houdini/fragments/localSchema/react/src/api/+schema.js @@ -8,7 +8,7 @@ export default createSchema({ `, resolvers: { Query: { - hello: () => 'world', + hello: () => 'Greetings from your local api 👋', }, }, }) diff --git a/packages/create-houdini/fragments/localSchema/react/src/routes/+page.gql b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.gql new file mode 100644 index 0000000000..210dadf14f --- /dev/null +++ b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.gql @@ -0,0 +1,3 @@ +query HelloHoudini { + hello +} diff --git a/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx new file mode 100644 index 0000000000..cee4147c46 --- /dev/null +++ b/packages/create-houdini/fragments/localSchema/react/src/routes/+page.jsx @@ -0,0 +1,9 @@ +export default function ({ Hello }) { + return ( +
+

Home

+ +

{Hello.message}

+
+ ) +} diff --git a/packages/create-houdini/templates/react-typescript/src/routes/+page.tsx b/packages/create-houdini/templates/react-typescript/src/routes/+page.tsx index a623b47302..2e844bcb99 100644 --- a/packages/create-houdini/templates/react-typescript/src/routes/+page.tsx +++ b/packages/create-houdini/templates/react-typescript/src/routes/+page.tsx @@ -2,7 +2,7 @@ import type { PageProps } from './$types' export default function ({}: PageProps) { return ( -
+

Home

diff --git a/packages/create-houdini/templates/react/src/routes/+page.jsx b/packages/create-houdini/templates/react/src/routes/+page.jsx index 27cfdb6544..41c7522979 100644 --- a/packages/create-houdini/templates/react/src/routes/+page.jsx +++ b/packages/create-houdini/templates/react/src/routes/+page.jsx @@ -1,6 +1,6 @@ export default function () { return ( -

+

Home

diff --git a/packages/create-houdini/templates/sveltekit-demo/.env.local b/packages/create-houdini/templates/sveltekit-demo/.env.local deleted file mode 100644 index 8e24f9ebfb..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.env.local +++ /dev/null @@ -1 +0,0 @@ -PUBLIC_GRAPHQL_ENDPOINT = 'API_URL' \ No newline at end of file diff --git a/packages/create-houdini/templates/sveltekit-demo/.eslintignore b/packages/create-houdini/templates/sveltekit-demo/.eslintignore deleted file mode 100644 index 38972655fa..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.eslintignore +++ /dev/null @@ -1,13 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example - -# Ignore files for PNPM, NPM and YARN -pnpm-lock.yaml -package-lock.json -yarn.lock diff --git a/packages/create-houdini/templates/sveltekit-demo/.graphqlrc.yaml b/packages/create-houdini/templates/sveltekit-demo/.graphqlrc.yaml deleted file mode 100644 index b2b9055a5c..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.graphqlrc.yaml +++ /dev/null @@ -1,9 +0,0 @@ -projects: - default: - schema: - - ./schema.graphql - - ./$houdini/graphql/schema.graphql - documents: - - '**/*.gql' - - '**/*.svelte' - - ./$houdini/graphql/documents.gql diff --git a/packages/create-houdini/templates/sveltekit-demo/.meta.gitignore b/packages/create-houdini/templates/sveltekit-demo/.meta.gitignore deleted file mode 100644 index c0a085dabe..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.meta.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -!.env.example -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -$houdini diff --git a/packages/create-houdini/templates/sveltekit-demo/.meta.json b/packages/create-houdini/templates/sveltekit-demo/.meta.json deleted file mode 100644 index 4250aba953..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.meta.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "SvelteKit - Demo", - "hint": "Light demo with a few pages, layout, queries. TypeScript", - "apiUrl": "https://houdinigraphql.com/graphql" -} diff --git a/packages/create-houdini/templates/sveltekit-demo/.npmrc b/packages/create-houdini/templates/sveltekit-demo/.npmrc deleted file mode 100644 index 0c05da457e..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -engine-strict=true -resolution-mode=highest diff --git a/packages/create-houdini/templates/sveltekit-demo/.prettierignore b/packages/create-houdini/templates/sveltekit-demo/.prettierignore deleted file mode 100644 index 88258c93c4..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.prettierignore +++ /dev/null @@ -1,15 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example - -# Ignore files for PNPM, NPM and YARN -pnpm-lock.yaml -package-lock.json -yarn.lock - -$houdini \ No newline at end of file diff --git a/packages/create-houdini/templates/sveltekit-demo/.prettierrc b/packages/create-houdini/templates/sveltekit-demo/.prettierrc deleted file mode 100644 index a77fddea90..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/.prettierrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100, - "plugins": ["prettier-plugin-svelte"], - "pluginSearchDirs": ["."], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] -} diff --git a/packages/create-houdini/templates/sveltekit-demo/README.md b/packages/create-houdini/templates/sveltekit-demo/README.md deleted file mode 100644 index bb54766ca5..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# create-houdini - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -You will lean the rest on the Home page of the demo app. - -More info on: https://github.com/HoudiniGraphql/houdini diff --git a/packages/create-houdini/templates/sveltekit-demo/houdini.config.js b/packages/create-houdini/templates/sveltekit-demo/houdini.config.js deleted file mode 100644 index 54d20b71e0..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/houdini.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/// - -/** @type {import('houdini').ConfigFile} */ -const config = { - watchSchema: { - url: 'env:PUBLIC_GRAPHQL_ENDPOINT' - }, - plugins: { - 'houdini-svelte': {} - } -}; - -export default config; diff --git a/packages/create-houdini/templates/sveltekit-demo/package.json b/packages/create-houdini/templates/sveltekit-demo/package.json deleted file mode 100644 index c7c3c2c3f6..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "PROJECT_NAME", - "version": "0.0.1", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "test": "npm run test:integration && npm run test:unit", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --plugin-search-dir . --check . && eslint .", - "format": "prettier --plugin-search-dir . --write .", - "test:integration": "playwright test", - "test:unit": "vitest" - }, - "devDependencies": { - "@playwright/test": "1.30.0", - "@sveltejs/adapter-auto": "^2.0.0", - "@sveltejs/kit": "^1.20.4", - "@typescript-eslint/eslint-plugin": "^5.45.0", - "@typescript-eslint/parser": "^5.45.0", - "eslint": "^8.28.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-svelte": "^2.30.0", - "houdini": "HOUDINI_VERSION", - "houdini-svelte": "HOUDINI_VERSION", - "prettier": "^2.8.0", - "prettier-plugin-svelte": "^2.10.1", - "svelte": "^4.0.5", - "svelte-check": "^3.4.3", - "tslib": "^2.4.1", - "typescript": "^5.0.0", - "vite": "^4.4.2", - "vitest": "^1.6.0" - }, - "type": "module" -} diff --git a/packages/create-houdini/templates/sveltekit-demo/playwright.config.ts b/packages/create-houdini/templates/sveltekit-demo/playwright.config.ts deleted file mode 100644 index 1c5d7a1fd3..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/playwright.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { PlaywrightTestConfig } from '@playwright/test'; - -const config: PlaywrightTestConfig = { - webServer: { - command: 'npm run build && npm run preview', - port: 4173 - }, - testDir: 'tests', - testMatch: /(.+\.)?(test|spec)\.[jt]s/ -}; - -export default config; diff --git a/packages/create-houdini/templates/sveltekit-demo/schema.graphql b/packages/create-houdini/templates/sveltekit-demo/schema.graphql deleted file mode 100644 index 27a17c06fe..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/schema.graphql +++ /dev/null @@ -1,23 +0,0 @@ -type Link { - name: String - url: String -} - -type Mutation { - hello(name: String!): String! -} - -type Query { - giveMeAnError: String - links(delai: Int): [Link!]! - sponsors: [Sponsor!]! - welcome: String! -} - -type Sponsor { - avatarUrl: String! - login: String! - name: String! - tiersTitle: String! - websiteUrl: String -} diff --git a/packages/create-houdini/templates/sveltekit-demo/src/app.d.ts b/packages/create-houdini/templates/sveltekit-demo/src/app.d.ts deleted file mode 100644 index f59b884c51..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/app.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface Platform {} - } -} - -export {}; diff --git a/packages/create-houdini/templates/sveltekit-demo/src/app.html b/packages/create-houdini/templates/sveltekit-demo/src/app.html deleted file mode 100644 index effe0d0d26..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -

%sveltekit.body%
- - diff --git a/packages/create-houdini/templates/sveltekit-demo/src/client.ts b/packages/create-houdini/templates/sveltekit-demo/src/client.ts deleted file mode 100644 index 5508157e5f..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/client.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PUBLIC_GRAPHQL_ENDPOINT } from '$env/static/public'; -import { HoudiniClient } from '$houdini'; - -export default new HoudiniClient({ - url: PUBLIC_GRAPHQL_ENDPOINT - - // uncomment this to configure the network call (for things like authentication) - // for more information, please visit here: https://www.houdinigraphql.com/guides/authentication - // fetchParams({ session }) { - // return { - // headers: { - // Authentication: `Bearer ${session.token}`, - // } - // } - // } -}); diff --git a/packages/create-houdini/templates/sveltekit-demo/src/index.test.ts b/packages/create-houdini/templates/sveltekit-demo/src/index.test.ts deleted file mode 100644 index e07cbbd725..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/index.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { describe, it, expect } from 'vitest'; - -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); -}); diff --git a/packages/create-houdini/templates/sveltekit-demo/src/lib/index.ts b/packages/create-houdini/templates/sveltekit-demo/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.gql b/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.gql deleted file mode 100644 index 5b3973d2a2..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.gql +++ /dev/null @@ -1,3 +0,0 @@ -query Layout { - welcome -} diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.svelte deleted file mode 100644 index 4e91c24004..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/+layout.svelte +++ /dev/null @@ -1,23 +0,0 @@ - - - - Houdini • demo - - - - -

{$Layout.data?.welcome}

- -Home | -Links | -Sponsors - -
- - diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/+page.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/+page.svelte deleted file mode 100644 index 4de98bb4aa..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ -

First of all, thank you for using Houdini 🎉!

-

- You will find here a very small app to show you a few featues like - +page.gql, +layout.gql, - fragment, data masking, - @loading -

-

To reset this demo and make it yours:

-
    -
  1. Remove all files in routes folder.
  2. -
  3. - Update .env.local so that - PUBLIC_GRAPHQL_ENDPOINT targets your endpoint. -
  4. -
  5. Restart the app.
  6. -
- -

//Enjoy 🥳🥳🥳

- - diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.gql b/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.gql deleted file mode 100644 index 15b5238515..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.gql +++ /dev/null @@ -1,8 +0,0 @@ -query PageHome { - links( - # The delai here is just to simulate a slow response from the server - delai: 3000 - ) @loading(count: 5) { - ...LinkInfo - } -} diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.svelte deleted file mode 100644 index 8e784216dd..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - -

Links

-
    - {#each $PageHome.data?.links ?? [] as link} -
  • - -
  • - {/each} -
diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/Link.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/links/Link.svelte deleted file mode 100644 index bc9d3a5171..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/links/Link.svelte +++ /dev/null @@ -1,39 +0,0 @@ - - -{#if $data.name === PendingValue} -
-{:else} - {$data.name} -{/if} - - diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.gql b/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.gql deleted file mode 100644 index ed8448f99c..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.gql +++ /dev/null @@ -1,6 +0,0 @@ -query PageSponsors { - sponsors { - ...SponsorInfo - tiersTitle - } -} diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.svelte deleted file mode 100644 index 796846d850..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/+page.svelte +++ /dev/null @@ -1,47 +0,0 @@ - - -

Sponsors

-
- {#if $PageSponsors.fetching} - Loading... - {:else if $PageSponsors.errors} - {#each $PageSponsors.errors as error} - {error.message} - {/each} - {:else} - {#each Object.entries(grouped) as [key, sponsors], i} - {@const size = 0.8 + (Object.entries(grouped).length - i) / 5} -

{key}

-
- {#each sponsors as sponsor} - - {/each} -
- {/each} - {/if} -
- - diff --git a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/Sponsors.svelte b/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/Sponsors.svelte deleted file mode 100644 index 73c84dc3de..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/src/routes/sponsors/Sponsors.svelte +++ /dev/null @@ -1,34 +0,0 @@ - - - - {$data.name} - {$data.name} - - - diff --git a/packages/create-houdini/templates/sveltekit-demo/static/favicon.png b/packages/create-houdini/templates/sveltekit-demo/static/favicon.png deleted file mode 100644 index 825b9e65af..0000000000 Binary files a/packages/create-houdini/templates/sveltekit-demo/static/favicon.png and /dev/null differ diff --git a/packages/create-houdini/templates/sveltekit-demo/svelte.config.js b/packages/create-houdini/templates/sveltekit-demo/svelte.config.js deleted file mode 100644 index 08e19ef2fb..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from '@sveltejs/adapter-auto'; -import { vitePreprocess } from '@sveltejs/kit/vite'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://kit.svelte.dev/docs/integrations#preprocessors - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - adapter: adapter(), - alias: { - $houdini: './$houdini' - } - } -}; - -export default config; diff --git a/packages/create-houdini/templates/sveltekit-demo/tests/test.ts b/packages/create-houdini/templates/sveltekit-demo/tests/test.ts deleted file mode 100644 index f8a9243559..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/tests/test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { expect, test } from '@playwright/test'; - -test('index page has expected h1', async ({ page }) => { - await page.goto('/'); - await expect(page.getByRole('heading', { name: 'Welcome to Houdini 🎩' })).toBeVisible(); -}); diff --git a/packages/create-houdini/templates/sveltekit-demo/tsconfig.json b/packages/create-houdini/templates/sveltekit-demo/tsconfig.json deleted file mode 100644 index 3cbd3c00fd..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "rootDirs": [".", "./.svelte-kit/types", "./$houdini/types"] - } -} diff --git a/packages/create-houdini/templates/sveltekit-demo/vite.config.ts b/packages/create-houdini/templates/sveltekit-demo/vite.config.ts deleted file mode 100644 index 521b2406b4..0000000000 --- a/packages/create-houdini/templates/sveltekit-demo/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import houdini from 'houdini/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [houdini(), sveltekit()] -});