File tree Expand file tree Collapse file tree 15 files changed +102
-92
lines changed
examples/react-github/src Expand file tree Collapse file tree 15 files changed +102
-92
lines changed Original file line number Diff line number Diff line change 88' @gqless/utils ' : patch
99---
1010
11- ## Cache
11+ ** Cache**
1212
1313- Support for Keys
14- - Support for circular references
14+ - They can now be used circularly
1515- Support for partial merging
1616
17- ## Optimizations
17+ ** Optimizations**
1818
1919- Heavily reduced cost of merging to cache
2020- Extension instances are now shared
2121- Internal lazy intialized & memoized changes
2222
23- ## Regressions
23+ ** Fixes **
2424
25- - Fragments need to be rewired, currently don't work
25+ - Scheduler is now smarter, works reliably with concurrent mode
26+ - Fragments containing selections with arguments now work
Original file line number Diff line number Diff line change 55 - Errors can make non-nullable fields return null
66
77- Make ` gqless ` bin alias to ` @gqless/cli ` , so only need to install 1 set of deps
8- - Make codegen default to typescript, add --js option
98- Make variable updates re-fetch & update component
10- - Default key logic should instead be moved to codegen. More explicit and no magic happening
9+ - Default key logic should be moved to codegen. More explicit and no magic happening
1110
1211- When we get an array
1312
2019# Improvements
2120
2221- Warn when \_\_ typename is accessed for React, without an ofType call
22+ - Support it as well
2323- Make toTree output deterministicly
2424- Prevent duplication in buildSelections
2525- Make Object.set default to ` match ` instead of setData
Original file line number Diff line number Diff line change @@ -4,9 +4,15 @@ import { graphql } from '@gqless/react'
44
55export const Repo = graphql (
66 ( { repo } : { repo : Types . Repository } ) => {
7+ // if (ofType(repo.owner, 'Organization')) {
8+ // console.log(repo.owner.organizationBillingEmail)
9+ // }
10+
711 return (
812 < div >
9- < h3 > { repo . name } </ h3 >
13+ < h3 >
14+ '{ repo . owner . __typename } ' { repo . name }
15+ </ h3 >
1016 { repo . descriptionHTML && (
1117 < p dangerouslySetInnerHTML = { { __html : repo . descriptionHTML } } />
1218 ) }
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ import * as Types from '../graphql'
33import { graphql , useFragment } from '@gqless/react'
44import { Repo } from './Repo'
55import styled from 'styled-components'
6- import { query } from '../graphql'
7- import { getAccessor } from 'gqless'
86
97const StyledUser = styled . div `
108 display: flex;
@@ -18,8 +16,7 @@ const Repos = styled.div`
1816
1917export const User = graphql (
2018 ( { user } : { user : Types . User } ) => {
21- let userFragment = user
22- userFragment = useFragment ( user )
19+ const userFragment = useFragment ( user )
2320
2421 const repos = userFragment . repositories ( {
2522 first : 100 ,
Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ import React from 'react'
22import ReactDOM from 'react-dom'
33import { App } from './App'
44
5- ReactDOM . render (
5+ ReactDOM . unstable_createRoot ( document . getElementById ( 'app' ) ) . render (
66 < React . Suspense fallback = "loading app" >
77 < App />
8- </ React . Suspense > ,
9- document . getElementById ( 'app' )
8+ </ React . Suspense >
109)
11-
12- Object . assign ( window , { } )
10+ // ReactDOM.render(
11+ // <React.Suspense fallback="loading app">
12+ // <App />
13+ // </React.Suspense>,
14+ // document.getElementById('app')
15+ // )
Original file line number Diff line number Diff line change @@ -97,21 +97,17 @@ export abstract class Accessor<
9797 }
9898
9999 public get data ( ) {
100- try {
101- if ( this . _data === undefined ) {
102- try {
103- this . data = this . getData ( )
104- } catch ( accessor ) {
105- if ( accessor instanceof Accessor ) return accessor . data
106-
107- throw accessor
108- }
109- }
100+ if ( this . fragmentToResolve ) {
101+ return this . fragmentToResolve . data
102+ }
110103
111- return this . _data
112- } finally {
113- accessorInterceptors . forEach ( ( intercept ) => intercept ( this ) )
104+ if ( this . _data === undefined ) {
105+ this . data = this . getData ( )
114106 }
107+
108+ accessorInterceptors . forEach ( ( intercept ) => intercept ( this ) )
109+
110+ return this . _data
115111 }
116112 public set data ( data : any ) {
117113 this . _data = data
@@ -295,11 +291,3 @@ export abstract class Accessor<
295291 }
296292 }
297293}
298-
299- export const getAccessorData = ( accessor : Accessor ) : any => {
300- if ( accessor . fragmentToResolve ) {
301- return getAccessorData ( accessor . fragmentToResolve )
302- }
303-
304- return accessor . data
305- }
Original file line number Diff line number Diff line change 11import { Generic , Mix } from 'mix-classes'
22
33import { IndexAccessor } from '../Accessor'
4- import { ACCESSOR , getAccessorData } from './ ../Accessor'
4+ import { ACCESSOR } from '../Accessor'
55import {
66 NodeContainer ,
77 Matchable ,
@@ -93,7 +93,7 @@ export class ArrayNode<TNode> extends Mix(
9393 ctx . accessor . get ( index ) ||
9494 new IndexAccessor ( ctx . accessor , index )
9595
96- return getAccessorData ( accessor )
96+ return accessor . data
9797 }
9898
9999 return ( this . ofNode as any as DataTrait ) . getData ( {
Original file line number Diff line number Diff line change @@ -47,10 +47,8 @@ export class InterfaceNode<TImplementation>
4747
4848 return new Proxy ( data , {
4949 get : ( _ , prop : any ) => {
50- // if (accessor.fragmentToResolve) {
51- // const { data } = accessor.fragmentToResolve
52- // return data ? data[prop] : undefined
53- // }
50+ const fragment = ctx . accessor ?. fragmentToResolve
51+ if ( fragment ) return fragment . data ?. [ prop ]
5452
5553 // If the prop exists in this interface,
5654 // return directly from interface
@@ -78,11 +76,12 @@ export class InterfaceNode<TImplementation>
7876 } ,
7977
8078 set : ( _ , prop : string , value ) => {
81- // if (accessor.fragmentToResolve) {
82- // const { data } = accessor.fragmentToResolve
83- // if (data) data[prop] = value
84- // return true
85- // }
79+ const fragment = ctx . accessor ?. fragmentToResolve
80+ if ( fragment ) {
81+ const { data } = fragment
82+ if ( data ) data [ prop ] = value
83+ return true
84+ }
8685
8786 if ( prop === '__typename' ) return true
8887
Original file line number Diff line number Diff line change @@ -63,10 +63,8 @@ export class ObjectNode extends Mix(
6363
6464 return new Proxy ( { } as any , {
6565 get : ( _ , prop : any ) => {
66- // if (accessor.fragmentToResolve) {
67- // const { data } = accessor.fragmentToResolve
68- // return data ? data[prop] : undefined
69- // }
66+ const fragment = ctx . accessor ?. fragmentToResolve
67+ if ( fragment ) return fragment . data ?. [ prop ]
7068
7169 if ( prop === ACCESSOR ) return ctx . accessor
7270 // Statically resolve __typename
@@ -89,11 +87,12 @@ export class ObjectNode extends Mix(
8987 } ,
9088
9189 set : ( _ , prop : string , value ) => {
92- // if (accessor.fragmentToResolve) {
93- // const { data } = accessor.fragmentToResolve
94- // if (data) data[prop] = value
95- // return true
96- // }
90+ const fragment = ctx . accessor ?. fragmentToResolve
91+ if ( fragment ) {
92+ const { data } = fragment
93+ if ( data ) data [ prop ] = value
94+ return true
95+ }
9796
9897 if ( prop === '__typename' ) return true
9998
Original file line number Diff line number Diff line change @@ -50,10 +50,8 @@ export class Abstract<TNode extends ObjectNode = ObjectNode>
5050 { } ,
5151 {
5252 get ( _ , prop : any ) {
53- // if (accessor.fragmentToResolve) {
54- // const { data } = accessor.fragmentToResolve
55- // return data ? data[prop] : undefined
56- // }
53+ const fragment = ctx . accessor ?. fragmentToResolve
54+ if ( fragment ) return fragment . data ?. [ prop ]
5755
5856 if ( prop === ACCESSOR ) return ctx . accessor
5957
@@ -71,11 +69,12 @@ export class Abstract<TNode extends ObjectNode = ObjectNode>
7169 } ,
7270
7371 set ( _ , prop : any , value : any ) {
74- // if (accessor.fragmentToResolve) {
75- // const { data } = accessor.fragmentToResolve
76- // if (data) data[prop] = value
77- // return true
78- // }
72+ const fragment = ctx . accessor ?. fragmentToResolve
73+ if ( fragment ) {
74+ const { data } = fragment
75+ if ( data ) data [ prop ] = value
76+ return true
77+ }
7978
8079 // else set it on the first extension with the property
8180 for ( const extension of getExtensions ( ctx ) ) {
You can’t perform that action at this time.
0 commit comments