INIT commit

This commit is contained in:
Michal Kváček
2023-05-31 20:44:10 +02:00
commit a3e8917db5
73 changed files with 5405 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import {ApolloClient, ApolloLink, HttpLink, InMemoryCache} from '@apollo/client/core'
import {createApolloProvider} from "@vue/apollo-option";
const httpLink = new HttpLink({
uri: 'http://localhost:8000/graphql',
credentials: 'include'
})
export const apolloClient = new ApolloClient({
link: ApolloLink.from([httpLink]),
cache: new InMemoryCache(),
connectToDevTools: true,
})
export const apolloWrapper = {
query(query, variables = {}) {
return apolloClient.query({
query: query,
fetchPolicy: 'no-cache',
variables: variables
})
.then((response) => response)
.catch(err => {
console.error("Error during query: ", err)
})
},
mutate(mutation, variables, onUpdate = () => {}) {
return apolloClient
.mutate({
mutation: mutation,
fetchPolicy: 'no-cache',
variables: variables,
update: () => {
onUpdate();
},
})
.then((response) => response)
.catch(err => {
console.error("Error during mutation: ", err);
})
},
}
// @see https://v4.apollo.vuejs.org/migration/
export const apolloProvider = createApolloProvider({
defaultClient: apolloClient,
})
+11
View File
@@ -0,0 +1,11 @@
import gql from "graphql-tag";
export const FRAGMENT_AIRCRAFT_FULL_INFO = gql`
fragment aircraftFullInfo on Aircraft {
id
name
model
description
manufacturer
}
`;
+39
View File
@@ -0,0 +1,39 @@
import gql from "graphql-tag";
import {FRAGMENT_AIRCRAFT_FULL_INFO} from "src/graphql/fragments/aircraft";
export const CREATE_AIRCRAFT = gql`
mutation createAircraft($input: CreateAircraftInput!) {
createAircraft(input: $input) {
...aircraftFullInfo
}
}
${FRAGMENT_AIRCRAFT_FULL_INFO}
`;
export const EDIT_AIRCRAFT = gql`
mutation editAircraft($id: Int!, $input: EditAircraftInput!) {
editAircraft(id: $id, input: $input) {
...aircraftFullInfo
}
}
${FRAGMENT_AIRCRAFT_FULL_INFO}
`;
export const DELETE_AIRCRAFT = gql`
mutation deleteAircraft($id: Int!) {
deleteAircraft(id: $id) {
id
}
}
`;
// export const CREATE_CAMPAIGN = gql`
// mutation createCampaign($input: CreateCampaignMutationInput!) {
// createCampaign(input: $input) {
// campaign {
// id
// }
// }
// }
// `;
+23
View File
@@ -0,0 +1,23 @@
import gql from "graphql-tag";
import {FRAGMENT_AIRCRAFT_FULL_INFO} from "src/graphql/fragments/aircraft";
export const AIRCRAFTS_LIST = gql`
query AircraftsList {
aircrafts {
...aircraftFullInfo
}
}
${FRAGMENT_AIRCRAFT_FULL_INFO}
`;
export const AIRCRAFT_DETAIL = gql`
query AircraftDetail($id: Int!) {
aircraft(id: $id) {
...aircraftFullInfo
}
}
${FRAGMENT_AIRCRAFT_FULL_INFO}
`;
+10
View File
@@ -0,0 +1,10 @@
import gql from "graphql-tag";
export const FLIGHTS_LIST = gql`
query FlightsList {
flights {
name
id
}
}
`;