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

Issue with null fields #21

Closed
averyaube opened this issue Feb 1, 2018 · 2 comments · Fixed by #26
Closed

Issue with null fields #21

averyaube opened this issue Feb 1, 2018 · 2 comments · Fixed by #26

Comments

@averyaube
Copy link

Hey,

I've just started implementing this library into a project, and it's really cool so far! I've run into an issue though.

If I make a query with a null field, I receive the following error:

TypeError: Cannot use 'in' operator to search for '__typename' in null
    at http://localhost:4001/static/js/bundle.js:52195:24
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at http://localhost:4001/static/js/bundle.js:52199:7
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at http://localhost:4001/static/js/bundle.js:52199:7
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at http://localhost:4001/static/js/bundle.js:52199:7
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at http://localhost:4001/static/js/bundle.js:52199:7
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at http://localhost:4001/static/js/bundle.js:52199:7
    at Array.map (<anonymous>)
    at getTypeNameFromField (http://localhost:4001/static/js/bundle.js:52193:20)
    at gankTypeNamesFromResponse (http://localhost:4001/static/js/bundle.js:52186:3)
    at http://localhost:4001/static/js/bundle.js:51930:128
    at <anonymous>

As soon as I remove that field, everything works again. Not sure if perhaps I am missing something, but figured I should pass this along. Thanks!

@averyaube
Copy link
Author

Also just for a bit more information: the field is marked as nullable in my GraphQL API, and the API does successfully return a response with the field as a null value. Thanks!

@kenwheeler
Copy link
Contributor

I'll get this sorted out in the morning

kenwheeler added a commit that referenced this issue Feb 2, 2018
@kenwheeler kenwheeler mentioned this issue Feb 2, 2018
kitten added a commit that referenced this issue Feb 5, 2020
* Add helpers in exchange to detect mutations

* Implement writeOptimistic in write operation

Left lottttts of TODOs

* Add internal store state

* Integrate global state into query and write

* Run optimistic updates in exchange

* Add processDependencies to optimisticUpdate

* Remove setting data to null for empty query results

This shouldn't be necessary.
The exchange should always decide whether to use
a result or not based on the completeness

* (fix) - write with addTodo as a rootField

* (tests) - add optimisticWrite and dep tests

* (refactor) - clean up fix

* (chore) - add explanatory comment

* (tests) - allow for dependency testing

* (refactor) - use the right fix

* (tests) - test store.clearOptimistic
kitten pushed a commit that referenced this issue Feb 14, 2020
Fix issue where line appears towards bottom of sidebar bg on high res
parkerziegler pushed a commit that referenced this issue Feb 28, 2020
* Convert example 2 to TypeScript

* Add `tsconfig.json` and `next-env.d.ts`
* JS -> TS conversion
* Add types for pokemon data
* Add type for Next App
* Refactor pokemon type mapping

* Use AppPropsType from Next
parkerziegler added a commit that referenced this issue Mar 1, 2020
* Initial commit.

* Check in initial work on README before beginning API rework.

* Add setup for Babel, Rollup, Jest. Begin working on NextJS example.

* Add next.config.js to example. Being to isolate peerDependencies.

* Check in progress on example and rollup config.

* Add bash script to assist in example dependency installation. Add API doscumentation and example README instructions.

* Add Pokemon type icons to example.

* README edits.

* Last cleanup before 0.1.0 publish.

* Check in initial CHANGELOG. Add npm badge to repo.

* Add example CodeSandbox link to repo.

* Improve publishing steps. Add formal LICENSE. Improve documentation. Add TypeScript definitions. (#2)

* Improve publishing steps. Add formal LICENSE. Improve documentation. Add TypeScript definitions.

* Remove declaration: true from tsconfig.

* PR feedback. Improve README language around automatic static optimization. Add CONTRIBUTING.md. Adjust ESLint settings.

* Changes for version 0.1.1

* v0.1.1

* Add support for accessing Next context to configure urql Client. (#4)

* Add support for accessing ctx in withUrqlClient.

* Update TS definitions. Add test of mergeExchanges.

* Add updated documentation on accessing ctx in withUrqlClient. Update CHANGELOG for v0.2.0 release.

* v0.2.0

* Prevent circular structure in getInitialProps. (#7)

* Prevent circular structure in getInitialProps.

* Update TS defs to better match wrapped components that implement their own getInitialProps.

* Final edits to index.d.ts.

* Prepare v0.2.1 release.

* v0.2.1

* Fix first argument type for withUrqlClient (#9)

* Prepare v0.2.2 release.

* v0.2.2

* Fix a few typos in the README.

* Fix support for using withUrqlClient with _app.js. (#13)

* Fix support for using withUrqlClient with _app.js

Co-authored-by: bmathews <brian.mathews@formidable.com>

* Update example READMEs.

* Final adjustments to index.d.ts

Co-authored-by: Brian Mathews <spoonart@gmail.com>

* Prepare v0.2.3 release.

* v0.2.3

* add urqlClient to Page Context (#15)

* add urqlClient to Page Context

* revert import ordering

* add urqClient to PageProps interface in index.d.ts

* move type to NextContextWithAppTree

* Prepare 0.2.4 release.

* Add urqlClient to mocked Next context object.

* v0.2.4

* chore: Convert example `1-with-urql-client` to TypeScript (#19)

* Add auto-generated tsconfig.json and next-env.d.ts

* Convert components and pages to TypeScript

* Use correct NextContext type

* Point TS compiler to next-urql at root of the repo

* Update example to use our custom NextContext

* chore: Convert example `2-with-_app.js` to TypeScript (#21)

* Convert example 2 to TypeScript

* Add `tsconfig.json` and `next-env.d.ts`
* JS -> TS conversion
* Add types for pokemon data
* Add type for Next App
* Refactor pokemon type mapping

* Use AppPropsType from Next

* Upgrade to Next 9 (#22)

* Upgrade to Next 9 (test fixes WIP)

* Remove deprecated `@types/next`
* Add `next@9.1.7` to devDependencies
* Replace `NextComponentClass` | `NextFC` union describing `Page` with
`NextPage`
* Rename `NextContextWithAppTree` to `NextUrqlContext`
* Make `NextUrqlContext` extend `NextPageContext` instead of
`NextContext`

* Import types directly from top-level next

* Coerce mock request object

* Fix withUrqlClient test config

* Coerce ctx into more accurate representation

* Prepare v0.2.5.

* v0.2.5

* Add instructions on using next-urql with ReasonML. (#28)

* Update for missing peer dependencies (#29)

* Add Travis CI. Autogenerate TS defs into dist. Add displayName for development environments. (#30)

* Add Travis CI. Autogenerate TS defs into dist. Add displayName for development environments.

* Fix issues with Rollup not transforming regeneratorRuntime in examples.

* Use correct name for formatting script in CI.

* Add in Buble.

* Preserve displayName in all environments. Add build badge to README.

* Add custom exchange example (#32)

* Add initial custom exchange example

* Remove console log

* Remove serialization of clientOptions in getInitialProps. (#33)

* Remove serialization of clientOptions in getInitialProps.

* Remove unnecessary console.log.

* Remove another console.log.

* Move mockMergeExchanges to upper describe block.

* Move beforeEach rendering component into relevant describe block.

* Remove test stage as Travis explicitly includes it.

* bump react-ssr-prepass to 1.1.2 to fix the suspense bug (#37)

* bump react-ssr-prepass to 1.1.1 to fix the suspense bug

* use 1.1.2 this includes some refactors

* Add better support for _app.js. Move types to separate module. (#38)

* Add better support for _app.js. Move types to separate module.

* Remove unnecessary type casting.

* Fix type issues in tests by relaxing types 😂

* Prepare v0.3.0 release.

* v0.2.0

* v0.3.0

* Demonstrate usage of getInitialProps in _app.js. (#40)

* Clean up old next-urql configs

* Fix build for next-urql

* Add correct next-urql test setup

* Lint next-urql files

* Update CHANGELOG and add changeset to next-urql

* Remove .gitignore in individual files. Edit README.

Co-authored-by: Kyle Alwyn <kjalwyn@gmail.com>
Co-authored-by: Brian Mathews <spoonart@gmail.com>
Co-authored-by: Björn Rave <36173920+BjoernRave@users.noreply.github.com>
Co-authored-by: Ryan Gilbert <ryangilbert7926@gmail.com>
Co-authored-by: Ayhan <ayhankuru@yandex.com.tr>
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants