Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
!API ||
typeof API.graphql !== 'function' ||
typeof API.getGraphqlOperationType !== 'function'
) {
throw new Error(
'No API module found, please ensure @aws-amplify/api is imported'
);
}
const hasValidQuery =
query && API.getGraphqlOperationType(query) === 'query';
const hasValidMutation =
mutation && API.getGraphqlOperationType(mutation) === 'mutation';
const hasValidSubscription =
subscription &&
API.getGraphqlOperationType(subscription.query) === 'subscription';
if (!hasValidQuery && !hasValidMutation && !hasValidSubscription) {
console.warn('No query, mutation or subscription was specified');
}
if (hasValidQuery) {
try {
data = null;
const response = await API.graphql({ query, variables });
data = response.data;
} catch (err) {
data = err.data;
errors = err.errors;
}
} = this.props;
let { data, mutation: mutationProp, errors } = this.getDefaultState();
if (
!API ||
typeof API.graphql !== 'function' ||
typeof API.getGraphqlOperationType !== 'function'
) {
throw new Error(
'No API module found, please ensure @aws-amplify/api is imported'
);
}
const hasValidQuery =
query && API.getGraphqlOperationType(query) === 'query';
const hasValidMutation =
mutation && API.getGraphqlOperationType(mutation) === 'mutation';
const hasValidSubscription =
subscription &&
API.getGraphqlOperationType(subscription.query) === 'subscription';
if (!hasValidQuery && !hasValidMutation && !hasValidSubscription) {
console.warn('No query, mutation or subscription was specified');
}
if (hasValidQuery) {
try {
data = null;
const response = await API.graphql({ query, variables });
let { data, mutation: mutationProp, errors } = this.getDefaultState();
if (
!API ||
typeof API.graphql !== 'function' ||
typeof API.getGraphqlOperationType !== 'function'
) {
throw new Error(
'No API module found, please ensure @aws-amplify/api is imported'
);
}
const hasValidQuery =
query && API.getGraphqlOperationType(query) === 'query';
const hasValidMutation =
mutation && API.getGraphqlOperationType(mutation) === 'mutation';
const hasValidSubscription =
subscription &&
API.getGraphqlOperationType(subscription.query) === 'subscription';
if (!hasValidQuery && !hasValidMutation && !hasValidSubscription) {
console.warn('No query, mutation or subscription was specified');
}
if (hasValidQuery) {
try {
data = null;
const response = await API.graphql({ query, variables });
data = response.data;
} catch (err) {