Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
rtk-query-graphql
Advanced tools
Readme
Provides the facility to make requests to a graphql server
npm install rtk-query-graphql
yarn add rtk-query-graphql
A list of available properties can be found below. These must be passed to the containing graphqlFetch
method.
Property | Type | Description |
---|---|---|
url | string | server url. |
prepareHeaders | function | return two functions, one on each parameter; 1- setHeaders , 2- setHeader |
import { createApi } from "@reduxjs/toolkit/query/react";
import { graphqlFetch } from "rtk-query-graphql";
import gql from "graphql-tag";
interface IFruits {
id: number;
fruit_name: string;
}
interface IData {
data: { filterFruitsFam: IFruits[] };
}
const FILTER_FRUITS_FAM = gql`
query FilterFruitsFam($family: String) {
filterFruitsFam(family: $family) {
id
scientific_name
tree_name
fruit_name
family
origin
description
bloom
maturation_fruit
life_cycle
climatic_zone
}
}
`;
const fruitApi = createApi({
reducerPath: "fruitApi",
baseQuery: graphqlFetch({
url: "https://fruits-api.netlify.app/graphql",
prepareHeaders: (setHeaders, setHeader) => {
// replace all headers with this new object
setHeaders({
authToken: "tokenValue",
});
// you add a header and this is concatenated with the other existing headers
setHeader("authToken", "tokenValue");
},
}),
endpoints: (builder) => ({
filterFruitsFam: builder.query<IData, { family: string }>({
query: (variables) => ({
document: FILTER_FRUITS_FAM,
variables,
}),
}),
}),
});
const { useFilterFruitsFamQuery } = fruitApi;
export default function Test() {
let content;
const { data, isLoading } = useFilterFruitsFamQuery({ family: "Rosaceae" });
if (isLoading) content = <div>Loading...</div>;
if (data) {
content = (
<div>
{data.data.filterFruitsFam.map((fruit) => (
<div key={fruit.id}>
<p> {fruit.id}</p>
<p> {fruit.fruit_name}</p>
</div>
))}
</div>
);
}
return <>{content}</>;
}
FAQs
It helps you to make queries to a server that is using graphql
The npm package rtk-query-graphql receives a total of 11 weekly downloads. As such, rtk-query-graphql popularity was classified as not popular.
We found that rtk-query-graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.