Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test lib - 1st try #8

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build/*
/node_modules/*
/public/*
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
rules: {
"@typescript-eslint/consistent-type-imports": "off",
},
};

// NOTE!!!!
Expand Down
13 changes: 13 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Setup Action"
description: "Setup env for running actions"
runs:
using: "composite"
steps:
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "20.5.1"

- name: Install Dependencies
run: yarn install
shell: bash
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint

on: [push]

jobs:
run:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Repo
uses: ./.github/actions/setup

- name: Run linting
run: yarn lint
16 changes: 16 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Typescript Type Check

on: [push]

jobs:
run:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Repo
uses: ./.github/actions/setup

- name: Run tsc
run: yarn tsc
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ node_modules
/.cache
/build
/public/build
.env
/app/@types
# .env

3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"graphql.vscode-graphql",
"graphql.vscode-graphql-syntax",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss"
"bradlc.vscode-tailwindcss",
"github.vscode-github-actions"
]
}
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)
# Welcome to Performa!

## Development

From your terminal:

```sh
npm run dev
yarn dev
```

This starts your app in development mode, rebuilding assets on file changes.
Expand All @@ -17,13 +15,13 @@ This starts your app in development mode, rebuilding assets on file changes.
First, build your app for production:

```sh
npm run build
yarn build
```

Then run the app in production mode:

```sh
npm start
yarn start
```

Now you'll need to pick a host to deploy it to.
Expand Down Expand Up @@ -56,3 +54,21 @@ rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app
```

## Generate GraphQL types

run `yarn graphql`
if it fails, run `yarn graphql --verbose`
Note: GraphQL is introspective. This means you can query a GraphQL schema for details about itself.

## Helps / Docs

- GraphQL Integration
- https://www.apollographql.com/blog/apollo-client/how-to-use-apollo-client-with-remix/
- Authentication:
- Remix Auth: https://github.com/sergiodxa/remix-auth
- Google Auth Strategy: https://github.com/pbteja1998/remix-auth-google

# TODOs

Check todos here: https://github.com/mahmoudmoravej/testui/issues/2
66 changes: 66 additions & 0 deletions app/@types/fragment-masking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
import { FragmentDefinitionNode } from 'graphql';
import { Incremental } from './graphql';


export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
infer TType,
any
>
? [TType] extends [{ ' $fragmentName'?: infer TKey }]
? TKey extends string
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
: never
: never
: never;

// return non-nullable if `fragmentType` is non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
): TType;
// return nullable if `fragmentType` is nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
): TType | null | undefined;
// return array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
): ReadonlyArray<TType>;
// return array of nullable if `fragmentType` is array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): TType | ReadonlyArray<TType> | null | undefined {
return fragmentType as any;
}


export function makeFragmentData<
F extends DocumentTypeDecoration<any, any>,
FT extends ResultOf<F>
>(data: FT, _fragment: F): FragmentType<F> {
return data as FragmentType<F>;
}
export function isFragmentReady<TQuery, TFrag>(
queryNode: DocumentTypeDecoration<TQuery, any>,
fragmentNode: TypedDocumentNode<TFrag>,
data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
): data is FragmentType<typeof fragmentNode> {
const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
?.deferredFields;

if (!deferredFields) return true;

const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
const fragName = fragDef?.name?.value;

const fields = (fragName && deferredFields[fragName]) || [];
return fields.length > 0 && fields.every(field => data && field in data);
}
Loading
Loading