Mirror: The small sibling of the graphql package, slimmed down for client-side libraries.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

(chore) - introduce size check (#1)

* Switch to graphql@16 alpha

* prepare size check

* add command

* only compare vendor

* formatting

* convert to preact

Co-authored-by: Phil Pluckthun <phil@kitten.sh>

authored by

Jovi De Croock
Phil Pluckthun
and committed by
GitHub
6c597156 5a3c8bb5

+154 -1
+45
.github/workflows/size.yml
··· 1 + name: compressed-size 2 + on: 3 + pull_request: 4 + branches: 5 + - main 6 + 7 + jobs: 8 + build: 9 + runs-on: ubuntu-latest 10 + steps: 11 + - uses: actions/checkout@v2 12 + 13 + - name: Setup Node 14 + uses: actions/setup-node@v1 15 + with: 16 + node-version: '14' 17 + 18 + - name: Get Yarn cache directory 19 + id: yarn-cache-dir-path 20 + run: echo "::set-output name=dir::$(yarn cache dir)" 21 + 22 + - name: Use Yarn cache 23 + uses: actions/cache@v2 24 + id: yarn-cache 25 + with: 26 + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 27 + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 28 + restore-keys: | 29 + ${{ runner.os }}-yarn- 30 + 31 + - name: Install Dependencies 32 + if: | 33 + steps.yarn-cache.outputs.cache-hit != 'true' || 34 + steps.node-modules-cache.outputs.cache-hit != 'true' 35 + run: yarn install --prefer-offline --frozen-lockfile --non-interactive --silent 36 + 37 + - name: Build GraphQL-Web-Lite 38 + run: yarn build 39 + 40 + - name: compressed-size-action 41 + uses: preactjs/compressed-size-action@v2 42 + with: 43 + pattern: '{demo/dist-graphql/assets/vendor.*.js,demo/dist-lite/assets/vendor.*.js}' 44 + build-script: size-check 45 + repo-token: '${{ secrets.GITHUB_TOKEN }}'
+3
.gitignore
··· 4 4 coverage/ 5 5 /cypress/videos/** 6 6 /cypress/screenshots/** 7 + demo/yarn.lock 8 + demo/dist-graphql 9 + demo/dist-lite
+12
demo/index.html
··· 1 + <!DOCTYPE html> 2 + <html lang="en"> 3 + <head> 4 + <meta charset="UTF-8"> 5 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 + <title>test</title> 7 + </head> 8 + <body> 9 + <div id="root"></div> 10 + <script type="module" src="/src/index.jsx"></script> 11 + </body> 12 + </html>
+19
demo/package.json
··· 1 + { 2 + "name": "demo", 3 + "version": "0.0.0", 4 + "private": true, 5 + "scripts": { 6 + "build": "yarn build:graphql && yarn build:lite", 7 + "build:graphql": "vite build", 8 + "build:lite": "vite build -c ./vite.alias.config.js" 9 + }, 10 + "dependencies": { 11 + "graphql": "^16.0.0-alpha.5", 12 + "preact": "^10.5.14", 13 + "@urql/preact": "^2.0.2" 14 + }, 15 + "devDependencies": { 16 + "@preact/preset-vite": "^2.1.0", 17 + "vite": "^2.2.4" 18 + } 19 + }
+34
demo/src/Pokemons.jsx
··· 1 + import { gql, useQuery } from '@urql/preact'; 2 + 3 + const POKEMONS_QUERY = gql` 4 + query Pokemons { 5 + pokemons(limit: 10) { 6 + id 7 + name 8 + } 9 + } 10 + `; 11 + 12 + const Pokemons = () => { 13 + const [result] = useQuery({ query: POKEMONS_QUERY }); 14 + 15 + const { data, fetching, error } = result; 16 + 17 + return ( 18 + <div> 19 + {fetching && <p>Loading...</p>} 20 + 21 + {error && <p>Oh no... {error.message}</p>} 22 + 23 + {data && ( 24 + <ul> 25 + {data.pokemons.map(pokemon => ( 26 + <li key={pokemon.id}>{pokemon.name}</li> 27 + ))} 28 + </ul> 29 + )} 30 + </div> 31 + ); 32 + }; 33 + 34 + export default PokemonList;
+15
demo/src/index.jsx
··· 1 + import { render } from 'preact'; 2 + import Pokemons from './Pokemons'; 3 + 4 + const client = createClient({ 5 + url: 'https://trygql.formidable.dev/graphql/basic-pokedex', 6 + }); 7 + 8 + render( 9 + <React.StrictMode> 10 + <Provider value={client}> 11 + <Pokemons /> 12 + </Provider> 13 + </React.StrictMode>, 14 + document.getElementById('root') 15 + );
+15
demo/vite.alias.config.js
··· 1 + import { defineConfig } from 'vite'; 2 + import path from 'path'; 3 + import preact from "@preact/preset-vite"; 4 + 5 + export default defineConfig({ 6 + plugins: [preact()], 7 + resolve: { 8 + alias: { 9 + graphql: path.resolve('..', './dist') 10 + } 11 + }, 12 + build: { 13 + outDir: './dist-lite' 14 + } 15 + });
+9
demo/vite.config.js
··· 1 + import { defineConfig } from 'vite'; 2 + import preact from "@preact/preset-vite"; 3 + 4 + export default defineConfig({ 5 + plugins: [preact()], 6 + build: { 7 + outDir: './dist-graphql' 8 + } 9 + });
+2 -1
package.json
··· 4 4 "main": "index.js", 5 5 "license": "MIT", 6 6 "scripts": { 7 - "build": "rollup -c scripts/rollup/config.js" 7 + "build": "rollup -c scripts/rollup/config.js", 8 + "size-check": "cd demo && yarn && yarn build" 8 9 }, 9 10 "homepage": "https://github.com/kitten/graphql-web-lite", 10 11 "bugs": {