https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# orm-help
  • c

    CCBCodeMonkey

    04/26/2019, 4:06 AM
    its one of the comments in that issue on github:
  • c

    CCBCodeMonkey

    04/26/2019, 4:07 AM
    it worked for me the other day, you gotta authenticate to heroku, there is some non informative error messages you get from docker
  • c

    CCBCodeMonkey

    04/26/2019, 4:07 AM
    Copy code
    Here'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 :)
  • s

    Sujit Singh

    04/26/2019, 10:37 AM
    Hello, I am facing issue with graphql schema, not sure if prisma has anything to do with it.. The issue is, I have schema as follows: type Link { id: ID! description: String! url: String! postedBy: User votes: [Vote!]! createdAt: DateTime! @createdAt } But when I run Node, it throws error as "Error: Field createdAt: Couldn't find type DateTime in any of the schemas.", If I replace DateTime with String, it throws error for @createdAt Directive: "Error: Directive createdAt: Couldn't find type createdAt in any of the schemas."
  • s

    Sven Haiges

    04/26/2019, 11:25 AM
    Hi all, I am trying to figure out how I can “hot reload” the schema and resolvers while the server is running. Is this possible at all? If not, I could think of a solution that involves the restart of a docker container and somehow outsource the resolvers and schema to seperate components. Wondering if anyone has tried this before and if there is a blueprint of what works?
  • s

    Sujit Singh

    04/26/2019, 11:27 AM
    Haven't tried this, but there seems to be a --watch flag for same
  • s

    Sujit Singh

    04/26/2019, 11:28 AM
    for deploy command
  • s

    Sven Haiges

    04/26/2019, 11:41 AM
    https://github.com/prisma/graphql-yoga/tree/master/examples/modular-resolvers
  • s

    Sven Haiges

    04/26/2019, 11:41 AM
    thx, I thinkthe example around modular resolvers is very close.
  • s

    Sven Haiges

    04/26/2019, 11:41 AM
    problem is I cannot get it up and running.
  • s

    Sven Haiges

    04/26/2019, 11:41 AM
    Copy code
    [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...
    threads 1
  • g

    Gaurav

    04/26/2019, 11:55 AM
    Hi all, I have two
    DateTime
    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 🙂
    • 1
    • 1
  • g

    Gaurav

    04/26/2019, 12:48 PM
    Hi everyone, need some help! I have to sync product info updates with algolia for which I am trying to write a cron job. This function gets IDs of all products which are not synced that is, freshly created or updated in DB but not in Algolia. CODE:
    Copy code
    // 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;
    };
  • r

    rem

    04/26/2019, 3:46 PM
    Is there info on heroku requirements for prisma (the backend - not my custom graphql server on top)? I've got a non-production use prisma server and it's topping out the memory on my client's default heroku instance: https://cloudup.com/cdFVuzpiti5
    👆 3
  • a

    Abdelmounaim Bousmat

    04/26/2019, 4:58 PM
    I want to ask question from a newbie 🙂. Should I use Appollo-Server 2 or GraphQL-Yoga and the best to use alongside with prisma?
    n
    • 2
    • 1
  • i

    impowski

    04/26/2019, 8:25 PM
    #help hey guys, how can I make an
    orderBy
    with a nested relation?
    b
    • 2
    • 2
  • h

    hocknas

    04/26/2019, 8:46 PM
    HOOOOLA
  • m

    Mihai

    04/26/2019, 9:15 PM
    Hey, I got a question, i copied the graphql-node from github , but when i run 'prisma deploy', i got this: × The field
    postedBy
    must provide a relation link mode. Either specify it on this field or the opposite field. Valid values are:
    @relation(link: INLINE)
  • m

    Mihai

    04/26/2019, 9:16 PM
    in fact, here are all the Errors: Errors: Link × The field
    postedBy
    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)
  • m

    Mihai

    04/26/2019, 9:16 PM
    I just copied the project, connected to mongoDB and run prisma deploy
  • j

    Jameson Brown

    04/27/2019, 12:48 AM
    I am running into an error I believe with calling a third party api in my resolver. Here is the code:
    Copy code
    const 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`:
    Copy code
    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:
    Copy code
    {
      "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.
    b
    • 2
    • 6
  • d

    Devion Villegas

    04/27/2019, 4:07 AM
    is 1gb of memory on a vm too little for prisma in production? getting crashes every other day which makes me think it's a memory leak but if you look at the github issues it seems fixed. Is there a beta version with no memory leak issues I can try? following the docs on a new vm easily reproduces the memory leak over a day or so.
  • m

    Morten Bo Rønsholdt

    04/27/2019, 1:39 PM
    hi peeps! I have the following datamodel:
    Copy code
    type 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:
    Copy code
    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-419494204
  • m

    Marcus Lindfeldt

    04/27/2019, 1:55 PM
    Hi, everyone! I'm looking for a setup that works both with a local database using e.g. docker-compose and a remote database e.g. AWS RDS. Basically I want to be able to fiddle around locally but then run my migrations against the remote db.
  • m

    Marcus Lindfeldt

    04/27/2019, 1:58 PM
    Do I need the prisma server to run all the time for prisma to work or is it just used to generate the client?
  • c

    cedric

    04/27/2019, 4:10 PM
    hi all, i'm doing a talk at https://www.gotochgo.com on monday (https://gotochgo.com/2019/sessions/917) and it will feature prisma as part of my api layer. my use case is to consume and cache playlists, artists, albums and tracks from the spotify api (https://developer.spotify.com/documentation/web-api/reference/artists/get-artist/). each of the objects in the spotify api use 22-character unique identifiers as ids. in an ideal world, it would be much simpler to use this string directly as a type id, but prisma only supports
    ID!
    ,
    UUID!
    and
    Int!
    types for ids. this results in mappings that look like this:
    Copy code
    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.
  • t

    Taylor

    04/27/2019, 6:29 PM
    Hi guys
  • t

    Taylor

    04/27/2019, 6:29 PM
    Does anyone why the @unique directive doesn't trigger an error when using Prisma with MongoDB connector?
  • t

    Taylor

    04/27/2019, 6:30 PM
    For some reason I'm able to save multiple instances of the same email to the db without any errors with the unique directive added like this // email: String! @unique
  • t

    Taylor

    04/27/2019, 6:39 PM
    @Harshit
1...261262263...637Latest