CCBCodeMonkey
04/26/2019, 4:06 AMCCBCodeMonkey
04/26/2019, 4:07 AMCCBCodeMonkey
04/26/2019, 4:07 AMHere's what I read:
I looked up prisma's latest docker hub tags at <https://hub.docker.com/r/prismagraphql/prisma/tags/> and picked 1.14-heroku (not sure what the difference is in *-heroku tags, but it sounded reasonable. Could someone from Prisma explain the difference?)
I read Heroku's docs on docker deployment and followed this section: <https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-existing-image>.
Here's the exact steps I ran:
Pulled the docker image w/ the tag mentioned above: docker pull prismagraphql/prisma:1.14-heroku
Looked up the image id from the image I just pulled using: docker images
Using that image id, I tagged it to my Heroku repo: docker tag b94e6d0d0939 <http://registry.heroku.com/${HEROKU_APP_NAME}/web|registry.heroku.com/${HEROKU_APP_NAME}/web>
Pushed the image to my heroku repo: docker push <http://registry.heroku.com/${HEROKU_APP_NAME}/web|registry.heroku.com/${HEROKU_APP_NAME}/web>
Finally, release this image to Heroku: heroku container:release web --app=${HEROKU_APP_NAME}
I did a bit of manual testing after the release and it seems OK, but I would caution other people from following this as I winged it :)
Sujit Singh
04/26/2019, 10:37 AMSven Haiges
04/26/2019, 11:25 AMSujit Singh
04/26/2019, 11:27 AMSujit Singh
04/26/2019, 11:28 AMSven Haiges
04/26/2019, 11:41 AMSven Haiges
04/26/2019, 11:41 AMSven Haiges
04/26/2019, 11:41 AMSven Haiges
04/26/2019, 11:41 AM[nodemon] 1.17.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `ts-node index.ts`
Error: "0" defined in resolvers, but not in schema
[nodemon] app crashed - waiting for file changes before starting...
Gaurav
04/26/2019, 11:55 AMDateTime
fields in datamodel
, updatedAt
and lastSyncedAt
. How could I get IDs of all records with lastSyncedAt
lesser than updatedAt
, that is, non-synced records?
Thank you 🙂Gaurav
04/26/2019, 12:48 PM// To sync with algolia, get products which are newly created or updated in DB only
const getProductIDsToSync = async (): Promise<string[]> => {
// DB call
/**
* [Execute raw SQL query from Prisma to compare columns from same row](<https://github.com/prisma/prisma/issues/3300#issuecomment-440801291>)
* Format: `SELECT * FROM "app-name$app-stage"."Table"`
*/
const query = `
SELECT id FROM "my-service$dev"."Product" WHERE algoliaSyncAt IS NULL OR updatedAt > algoliaSyncAt
`
.replace(/"/g, '\\"')
.replace(/\n/g, " ")
.replace(/\s+/g, " ");
// [Prisma graphql requests](<https://www.prisma.io/docs/prisma-client/basic-data-access/reading-data-TYPESCRIPT-rsc3/#graphql-requests>)
const response = await Prisma.$graphql(`
mutation {
executeRaw(query: "${query}")
}
`);
const productIDs: string[] = response.executeRaw.map(res => res.id);
return productIDs;
};
rem
04/26/2019, 3:46 PMAbdelmounaim Bousmat
04/26/2019, 4:58 PMimpowski
04/26/2019, 8:25 PMorderBy
with a nested relation?hocknas
04/26/2019, 8:46 PMMihai
04/26/2019, 9:15 PMpostedBy
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
Mihai
04/26/2019, 9:16 PMpostedBy
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
× The field votes
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
User
× The field links
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
× The field votes
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
Vote
× The field link
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
× The field user
must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are: @relation(link: INLINE)
Mihai
04/26/2019, 9:16 PMJameson Brown
04/27/2019, 12:48 AMconst getPackage = async (parent, args, context) => {
const package = await context.prisma.package({ date: args.date });
// If package exist return it, else, create new package
if (package) {
return package;
} else {
let pack = await context.prisma.createPackage({
date: args.date,
// Request Advice(error here - returns undefined/null)
advice: getAdvice(),
// Request Picture(pending - will use a third party API)
picture: `pic_${args.date}.jpg`,
// defaults empty array
comments: { set: [] }
});
return pack;
}
};
Here is my getAdvice()
function from `Helper.js`:
const getAdvice = () => {
// Get advice
axios
.get('<https://api.adviceslip.com/advice>')
.then(res => {
return res.data.slip.advice;
})
.catch(err => {
console.log(err);
return null;
});
};
module.exports = {
getAdvice
};
Here is my error:
{
"data": null,
"errors": [
{
"message": "Variable '$data' expected value of type 'PackageCreateInput!' but got: {\"date\":\"2019-4-24\",\"picture\":\"pic_2019-4-24.jpg\",\"comments\":{\"set\":[]}}. Reason: 'advice' Expected non-null value, found null. (line 1, column 11):\nmutation ($data: PackageCreateInput!) {\n ^",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"getPackage"
]
}
]
}
Any help would be great. I feel like I cant be to far off.Devion Villegas
04/27/2019, 4:07 AMMorten Bo Rønsholdt
04/27/2019, 1:39 PMtype Business {
id: ID! @id
stores: [Store]
}
type Store {
id: ID! @id
name: String!
business: Business!
}
I want to have a single mutation for updating both the Business
and Store
where the Business
serves as the entrypoint like so:
updateBusiness(
data: {
stores: {
create: {
name: 'My store'
}
}
},
where: {
id: 'some_business_id'
}
) {
id
stores {
name
business {
id
}
}
}
this works really well and I enjoy working with nested mutations. it makes the code much simpler. my challenge is how I implement authorization with this model. imagine a Person
that is a member of a specific `Business`: I need to avoid that this Person
creates a new Business
or connects a Store
from another Business
. it's easy to add authorization on the updateBusiness
mutation entrypoint via e.g. graphql-shield but once the Person
clears the initial check, the Person
can do whatever he/she wants via nested mutations further down.
should I just drop using nested mutations or is there a neat solution to this? I've managed to find a few people having the same issue but I don't see a good solution: https://github.com/prisma/prisma/issues/3901 and https://github.com/maticzav/graphql-shield/issues/113#issuecomment-419494204Marcus Lindfeldt
04/27/2019, 1:55 PMMarcus Lindfeldt
04/27/2019, 1:58 PMcedric
04/27/2019, 4:10 PMID!
, UUID!
and Int!
types for ids. this results in mappings that look like this:
type Artist {
id: ID! @id @unique # Generated by Prisma
artist_id: String! @unique # From Spotify
uri: String @unique
href: String @unique
genres: [Genre]! @relation(name: "ArtistToGenre")
...
}
It's manageable but a little noisy as i know have two "identifiers" in the prisma-exposed API. If I want to expose this API to the public, I worry this redundancy could be confusing for consumers (unless I use something nexus to omit the prisma-internal IDs from the public API programmatically). in case it comes up in Q&A after my talk, i was curious about the motivation for not allowing String
types as IDs. It seems there are quite a variety of use cases where Prisma might be used for a read-side abstraction of an existing data model or data set that has varchars as natural unique identifiers already.Taylor
04/27/2019, 6:29 PMTaylor
04/27/2019, 6:29 PMTaylor
04/27/2019, 6:30 PMTaylor
04/27/2019, 6:39 PM