Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function HomePage() {
const [name, setName] = React.useState('')
const { loading, data, error, refetch: refetchUsers } = useQuery(
HOMEPAGE_QUERY
)
const [createUser] = useMutation(CREATE_USER_MUTATION)
const [getFirstUser, { data: firstUserData }] = useManualQuery(
GET_FIRST_USER_QUERY,
{
fetchOptionsOverrides: {
method: 'GET'
}
}
)
async function createNewUser() {
await createUser({ variables: { name } })
setName('')
export default function PostList() {
const [skip, setSkip] = useState(0)
const { loading, error, data, refetch } = useQuery(allPostsQuery, {
variables: { skip, first: 10 },
updateData: (prevResult, result) => ({
...result,
allPosts: [...prevResult.allPosts, ...result.allPosts],
}),
})
if (error) return
if (!data) return <div>Loading</div>
const { allPosts, _allPostsMeta } = data
const areMorePosts = allPosts.length < _allPostsMeta.count
return (
const RegionBadenWuerttemberg = () => {
const classes = useStyles()
const { loading, error, data } = useQuery(query, {
variables: { id }
})
if (error) return <div>Error loading posts.</div>
if (loading) return <div>Loading</div>
const { WAHL09 } = data.region
return (
<h1>{name}</h1>
<p>
Baden-Wรผrttemberg ist nach Bayern und Nordrhein-Westfalen das
drittgrรถรte Bundesland Deutschlands, sowohl bei der Flรคche als auch</p>
function Posts() {
const { loading, error, data, refetch } = useQuery(allPostsQuery)
return (
<>
<h2>Add post</h2>
<h2>Posts</h2>
<button> refetch()}>Reload</button>
)
}
function GraphqlDemo() {
const [page, setPage] = useState(1);
const [searchInputValue, setSearchInputValue] = useState('');
useEffect(() => setPage(1), [searchInputValue]);
const { loading, error, data } = useQuery(GET_CHARACTERS, {
variables: { name: searchInputValue, page },
notifyOnNetworkStatusChange: true,
});
return (
<input placeholder="Filter by name (ex: Rick, Robot)"> setSearchInputValue(value)}
isLoading={loading}
/>
{error && (
export default function Posts() {
const { loading, data, error, refetch } = useQuery(allPostsQuery)
return (
<>
<h3>Add post</h3>
<h3>Posts</h3>
)
}
const Region = ({ slug, id, name }) => {
const { loading, error, data } = useQuery(allPostsQuery, {
variables: { id }
})
if (error) return <div>Error loading posts.</div>
if (loading) return <div>Loading</div>
const { WAHL09 } = data.region
return (
<h1>
{name} / {id} / {slug}
</h1>
<h3>Election results (2017)</h3>