daniele
11/12/2017, 9:43 PMpublic addAirline(airline: AddAirline): Observable<any> {
return this.apollo.mutate({
mutation: gql`
mutation($name: String!, $color: String!) {
createAirline(name: $name, color: $color){
id,
name,
color
}
}
`,
variables: {
name: airline.name,
color: airline.color
},
update: (proxy, { data: { createAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
data.allAirlines.push(createAirline);
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
}
daniele
11/12/2017, 9:43 PMdaniele
11/12/2017, 9:44 PMBung55
11/13/2017, 2:14 AMrussell
11/13/2017, 3:04 AMrahulkukadiya
11/13/2017, 7:57 AMkaaerreeene
11/13/2017, 8:42 AMtype Event @model {
id: ID! @isUnique
title: String!
description: String!
type: String
dateTime: DateTime!
location: String!
image: String
attendants: [Attendant!]! @relation(name: "EventHasAttendant")
minAttendants: Int!
maxAttendants: Int!
updatedAt: DateTime!
createdAt: DateTime!
}
My query is something like:
{
allEvents(filter: {dateTime: "2017-11-18T23:00:00.000Z"}) {
id
title
description
type
dateTime
location
image
attendants {
id
email
name
}
minAttendants
maxAttendants
}
}
Could you help me? I don't know if in this case I should use Graphcool Functions.bwoodlt
11/13/2017, 10:27 AMgraphql subscriptions
to work. I believe I set it up correctly, but it keep returning null. Here’s my setup const Subscription = new GraphQLObjectType({
name: 'RootSubscription',
description: 'All FathCircle Subscriptions',
fields: {
userCreated: {
type: UserLoginType,
subscribe: withFilter(
() => pubsub.asyncIterator(SUB.USER_CREATED, SUB.USER_LOGGED_IN),
(payload, args) => {
console.log(payload);
return payload.userCreated.id === args.id;
}
),
resolve: st => {
console.log(st);
console.log('Nothing shows!!!');
}
}})
bwoodlt
11/13/2017, 10:28 AMVinnie
11/13/2017, 10:29 AMcreateUser
without authorisation, I get stopped with an error for insufficient permissions, which is what I expect. However, when using the authorisation template providing the basic email/passwd auth, invoking the mutation signupUser
doesn’t yield any error, but actually creates the user, even though I can see the source code is (obviously) using the basic createUser
mutation.
Thoughts?daniele
11/13/2017, 11:04 AMAirline
on this table I perform CRUD operations. The CRUD operations are defined in my client project (angular with apollo). So my graphcool project atm contain just the schema definition:daniele
11/13/2017, 11:04 AMdaniele
11/13/2017, 11:04 AMtype Airline @model {
id: ID! @isUnique
name: String!
color: String!
}
daniele
11/13/2017, 11:05 AMdaniele
11/13/2017, 11:05 AM<https://github.com/graphcool/framework/tree/master/examples>
but I don't find any example to put the CRUD in functions or notdaniele
11/13/2017, 11:05 AMVinnie
11/13/2017, 11:07 AMVinnie
11/13/2017, 11:08 AMdaniele
11/13/2017, 11:08 AMdaniele
11/13/2017, 11:08 AMreturn this.apollo.mutate({
mutation: gql`
mutation($name: String!, $color: String!) {
createAirline(name: $name, color: $color){
id,
name,
color
}
}
`,
variables: {
name: airline.name,
color: airline.color
},
update: (proxy, { data: { createAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
data.allAirlines.push(createAirline);
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AMreturn this.apollo.mutate({
mutation: gql`
mutation($id:ID!, $name: String!, $color: String!) {
updateAirline(id: $id, name: $name, color: $color){
id,
name,
color
}
}
`,
variables: {
id: airline.id,
name: airline.name,
color: airline.color
},
update: (proxy, { data: { updateAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AMreturn this.apollo.mutate({
mutation: gql`
mutation($id:ID!) {
deleteAirline(id: $id){
id
}
}
`,
variables: {
id: airline.id
},
update: (proxy, { data: { deleteAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
const itemToDelete = data.allAirlines.findIndex((airlineToFilter) => airlineToFilter.id === deleteAirline.id);
data.allAirlines.splice(itemToDelete, 1);
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AM/* Retrieve the airline list */
private getAirlines = gql`{
allAirlines {
id
name
color
}
}`;
nilan
11/13/2017, 11:34 AMVinnie
11/13/2017, 12:19 PMjoar
11/13/2017, 12:21 PMjoar
11/13/2017, 12:22 PMMaslov
11/13/2017, 1:09 PMMaslov
11/13/2017, 1:09 PMMaslov
11/13/2017, 1:13 PM