johhansantana
07/11/2017, 11:45 PMbntzio
07/12/2017, 12:26 AMauser
07/12/2017, 12:35 AMauser
07/12/2017, 12:35 AMbntzio
07/12/2017, 12:36 AMauser
07/12/2017, 12:37 AMbntzio
07/12/2017, 12:38 AMbntzio
07/12/2017, 12:39 AMbe4r
07/12/2017, 4:35 AMm.gu
07/12/2017, 4:36 AMmika
07/12/2017, 6:06 AMmarcusstenbeck
07/12/2017, 6:51 AMStudent
, Enrollment
and Class
. Enrollment
needs a Class
and a Student
. Assume that Class
will always exist before both others. What’s the best approach to create a new Enrollment
and attach it to a Student
(and create that Student
if it does not exist)?frankspin
07/12/2017, 8:14 AMeraldo
07/12/2017, 10:25 AMauser
07/12/2017, 11:03 AMlewisblackwood
07/12/2017, 11:16 AMUser
, Organisation
and Team
. An organisation has many users, and many teams. I want to verify that a user can only list the teams that relate to the organisation it is a member of. I've got the following:
query ($user_id: ID!, $node_id: ID!) {
SomeUserExists(filter: {
id: $user_id
organisation: {
teams_some: {
id: $node_id
}
}
})
}
This works when trying to view another organisation's teams, with Insufficient permissions
returned. However, if the other organisation doesn't have any teams yet, the query will return { allTeams: [] }
. What's the best way to guard against this case? I'd still like to return Insufficient permissions
even if the other organisation doesn't have any teams.lewisblackwood
07/12/2017, 11:16 AMSomeTeamExists
samjbmason
07/12/2017, 12:43 PMUser -> Files
or just store the relevant data in the User modelfrankspin
07/12/2017, 5:09 PM// Query runs to start the subscription
const subQuery = gql`
subscription {
Client(filter: {
mutation_in: [CREATED, UPDATED, DELETED]
}) {
mutation
previousValues {
id
}
node {
id,
name,
createdAt
}
}
}`;
this.clientsSubscription = this.$apollo.queries.allClients.subscribeToMore({
document: subQuery,
// Mutate the previous result
updateQuery: (previousResult, { subscriptionData }) => {
const type = subscriptionData.data.Client.mutation;
const node = subscriptionData.data.Client.node || subscriptionData.data.Client.previousValues;
const state = previousResult.allClients;
switch(type) {
case 'CREATED':
// add new node to current state
this.allClients = [
...state,
node,
]
break;
case 'UPDATED':
// filter current state and update the selected item
this.allClients = state.map( (item) => {
if(item.id !== node.id) {
return item;
}
return {
...item,
...node
}
})
break;
case 'DELETED':
// filter delete node from current state
this.allClients = state.filter((item,) => item.id !== node.id );
break;
default:
return state;
}
},
});
},
mike.johnson
07/12/2017, 5:39 PMmike.johnson
07/12/2017, 5:40 PMagartha
07/12/2017, 7:28 PMkmarquardsen
07/12/2017, 7:39 PMnikolasburk
martin
07/12/2017, 8:16 PMInvalidStateError (DOM Exception 11): The object is in an invalid state.
https://github.com/graphcool-examples/react-graphql/blob/master/files-with-apollo/src/components/CreatePage.js#L48-L65martin
07/12/2017, 10:30 PMhandleDrop(files) {
let data = new FormData()
data.append('data', person.avatar)
fetch('<https://api.graph.cool/file/v1/___PROJECTID___>', {
method: 'POST',
body: data
})
[...]
The following works on a desktop/laptop, but not on mobile. For mobile, an empty image is produced, with the error `InvalidStateError (DOM Exception 11): The object is in an invalid state.`:
handleDrop(files) {
this.setState({ file: file[0] })
}
// Image is then cropped, upon which handleCrop() is called
handleCrop() {
// This returns a HTMLCanvasElement, it can be made into a data URL or a blob, drawn on another canvas, or added to the DOM.
const image = this.refs.avatar.getImageScaledToCanvas().toDataURL()
// Custom DataURLtoBlob() function
const blob = DataURLtoBlob(image)
let file = new File([blob], 'avatar.png', {
lastModified: new Date(),
type: "image/png"
})
let data = new FormData()
data.append('data', file)
fetch('<https://api.graph.cool/file/v1/___PROJECTID___>', {
method: 'POST',
body: data
})
[...]
}
pcooney10
07/12/2017, 11:25 PMreact-apollo
?pcooney10
07/12/2017, 11:26 PMCurrentUserForLayout
in this instance):
// The caller could do something like:
<ProfileWithData avatarSize={300} />
// And our HOC could look like:
const ProfileWithData = graphql(CurrentUserForLayout, {
options: ({ avatarSize }) => ({ variables: { avatarSize } }),
})(Profile);
pksunkara
07/12/2017, 11:57 PM@defaultValue
instead of shorter ones? @default
jt9001
07/13/2017, 1:38 AM