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

feat(graphql): generate types from graphql files #2014

Merged
merged 4 commits into from Apr 25, 2023
Merged

Conversation

Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Apr 18, 2023

Initialize the @affine/graphql package, you can run yarn workspace @affie/graphql gql-gen to generate src/graphql/index.ts and src/schema.ts files.

The src/graphql/index.ts is generated by packages/graphql-client/export-gql-plugin.cjs;

A SWR request wrapper has been written and placed in app/web/shared/gql.ts

Queries:

import { someQuery, someQueryWithNoVars } from '@affine/graphql'

const swrResponse1 = useQuery({
  query: workspaceByIdQuery,
  variables: { id: '1' }
})

const swrResponse2 = useQuery({
  query: someQueryWithNoVars
})

Mutations:

import { someMutation } from '@affine/graphql'

const { trigger } = useMutation({
  mutation: someMutation
})

trigger({ name: 'John Doe' })

@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Apr 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
affine-preview ✅ Ready (Inspect) Visit Preview Apr 25, 2023 1:24am
affine-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2023 1:24am

@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:41 — with GitHub Actions Inactive
@github-actions github-actions bot added the docs Improvements or additions to documentation label Apr 18, 2023
@cloudflare-pages
Copy link

cloudflare-pages bot commented Apr 18, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: fbeff35
Status: ✅  Deploy successful!
Preview URL: https://75521a04.affine.pages.dev
Branch Preview URL: https://gql-gen.affine.pages.dev

View logs

@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:44 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Patch coverage: 64.81% and project coverage change: -0.01 ⚠️

Comparison is base (4528df0) 74.11% compared to head (fbeff35) 74.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2014      +/-   ##
==========================================
- Coverage   74.11%   74.11%   -0.01%     
==========================================
  Files         297      301       +4     
  Lines        5958     6011      +53     
  Branches     1064     1075      +11     
==========================================
+ Hits         4416     4455      +39     
- Misses       1337     1346       +9     
- Partials      205      210       +5     
Flag Coverage Δ
e2etest 72.51% <ø> (+0.10%) ⬆️
server-test 90.78% <100.00%> (ø)
storybook-test 49.05% <ø> (ø)
unittest 35.31% <64.15%> (+0.39%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/graphql/src/fetcher.ts 53.65% <53.65%> (ø)
apps/server/src/config/index.ts 95.65% <100.00%> (ø)
apps/web/src/shared/gql.ts 100.00% <100.00%> (ø)
packages/graphql/src/graphql/index.ts 100.00% <100.00%> (ø)
packages/graphql/src/schema.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:46 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:49 — with GitHub Actions Inactive
@perfsee
Copy link

perfsee bot commented Apr 18, 2023

affine-toeverything

Bundle main

diff ------------------- Bundle Size Diff -------------------------

@@                       EntryPoint: main                        @@
##                     master        gql-gen                 +/- ##
===================================================================
< Bundle              4.27 MB        4.28 MB    +10.5 kB(+0.25%)   
< Initial JS          1.75 MB        1.75 MB      +979 B(+0.06%)   
= Initial CSS         13.2 kB        13.2 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   43             43                       
= Chunks                   41             41                       
= Packages                150            150                       
= Duplicates                5              5                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid non-minified assets                                        
! Avoid cache wasting                                              

@@                    EntryPoint: pages/_app                     @@
##                     master        gql-gen                 +/- ##
===================================================================
< Bundle              4.16 MB        4.17 MB    +10.5 kB(+0.25%)   
< Initial JS          1.65 MB        1.65 MB      +979 B(+0.06%)   
= Initial CSS         13.2 kB        13.2 kB                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                   41             41                       
= Chunks                   39             39                       
= Packages                150            150                       
= Duplicates                5              5                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#
! Deduplicate versions of libraries                                
! Separate mixed content assets files                              
! Avoid non-minified assets                                        
! Avoid cache wasting                                              

@@                   EntryPoint: pages/_error                    @@
##                     master        gql-gen                 +/- ##
===================================================================
= Bundle              16.7 kB        16.7 kB                       
= Initial JS          16.7 kB        16.7 kB                       
= Initial CSS             0 B            0 B                       
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
= Assets                    2              2                       
= Chunks                    2              2                       
= Packages                  5              5                       
= Duplicates                0              0                       

...and more

@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:50 — with GitHub Actions Inactive
@Brooooooklyn Brooooooklyn temporarily deployed to development April 18, 2023 08:50 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:18 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:21 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:24 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:24 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:24 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 24, 2023 17:24 — with GitHub Actions Inactive
@vercel vercel bot temporarily deployed to Preview – affine-preview April 24, 2023 17:28 Inactive
@vercel vercel bot temporarily deployed to Preview – affine-storybook April 24, 2023 17:32 Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:11 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:14 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:17 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:17 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:17 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:17 — with GitHub Actions Inactive
@himself65 himself65 temporarily deployed to development April 25, 2023 01:17 — with GitHub Actions Inactive
@vercel vercel bot temporarily deployed to Preview – affine-storybook April 25, 2023 01:18 Inactive
@vercel vercel bot temporarily deployed to Preview – affine-preview April 25, 2023 01:24 Inactive
@Brooooooklyn Brooooooklyn merged commit 5c673a8 into master Apr 25, 2023
22 of 24 checks passed
@Brooooooklyn Brooooooklyn deleted the gql-gen branch April 25, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:server app:web docs Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants