cv-graphql
v2.13.2
Published
Public cv-node GraphQL API types.
Downloads
46
Readme
cv-node generated types
Playground
https://cv-project-js.inno.ws/api/graphql
Query
Write GraphQL query
import { gql } from "@apollo/client";
export const LOGIN = gql`
query Login($auth: AuthInput!) {
login(auth: $auth) {
user {
id
email
}
access_token
}
}
`;
Create query arguments and response types
import type { AuthInput, AuthResult } from "cv-graphql";
export type LoginArgs = {
auth: AuthInput;
};
export type LoginResult = {
login: AuthResult;
};
Create login hook
export const useLogin = () => {
return useLazyQuery<LoginResult, LoginArgs>(LOGIN);
};
Mutation
Write GraphQL mutation
import { gql } from "@apollo/client";
export const SIGNUP = gql`
mutation Signup($auth: AuthInput!) {
signup(auth: $auth) {
user {
id
email
}
access_token
}
}
`;
Create mutation arguments and response types
import type { AuthInput, AuthResult } from "cv-graphql";
export type SignupArgs = {
auth: AuthInput;
};
export type SignupResult = {
signup: AuthResult;
};
Create signup hook
export const useSignup = () => {
return useMutation<SignupResult, SignupArgs>(SIGNUP);
};