@use-lens/react-apollo
Lens API generated code for Apollo Client in React.
⚠️ CAUTION
This API is beta and not production complete yet, which means that we could change schemas and endpoints at any time without warning or notice to you. When this API is production ready, we will remove this beta warning and will endeavor to ensure that there are no changes going forward unless a major change to the protocol itself is required.
Lens API is not production complete, and so is @use-lens/*
. Please, keep this in mind when going to production.
In case of breaking changes, please, visit main README.md's FAQ
There is an explanation of how I see the best use of @use-lens/*
at this point in the main README.md
🤓 Usage
All packages and CLI have 2 versions/dist-tags:
@testnet
and@latest
. Install@testnet
version only if you need some functionality from it(currently, it is onlycreateProfile
).
- Install package
npm install --save @use-lens/react-apollo
- Add Apollo: https://www.apollographql.com/docs/react/get-started
- Use generated code
import {
useAuthenticateMutation,
useChallengeLazyQuery,
useGlobalProtocolStatsQuery
} from '@use-lens/react-apollo';
const SomeComponent = () => {
// component's code
const [loadChallenge] = useChallengeLazyQuery();
const [authenticate] = useAuthenticateMutation();
const { data, error, loading } = useGlobalProtocolStatsQuery();
return // render data from Lens API.
}
Workflow
- decide what you want to implement
- go to
🌿 https://docs.lens.xyz to check what query or mutation you need to use - import from
@use-lens/react-apollo
what you need- document(query or mutation)
- request /response types
Detailed information about what is produced can be found here:
https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-apollo
👨🏫 Example
https://github.com/use-lens/use-lens/tree/main/examples/react-apollo
🔎 LICENSE
MIT. The full license text can be found in the LICENSE file.
...The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
⏲ Last update
2022/12/07