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

    cory

    08/22/2018, 8:05 AM
    Seems like Prisma confiscates the Heroku
    web
    process with
    /bin/sh -c /app/start.sh
    (Docker I’m guessing?)
  • c

    cory

    08/22/2018, 8:06 AM
    That is… is there a preferred/recommended deployment approach?
    a
    • 2
    • 3
  • g

    Gorodov Maksim

    08/22/2018, 9:50 AM
    Hey, guys, could u help me with this question? 🙂 https://www.prisma.io/forum/t/what-are-the-advantages-of-using-your-own-database/4213
  • p

    playerx

    08/22/2018, 10:35 AM
    Hello guys, just one quick question, I was using
    prisma:1.8
    , lets say schema looks like this:
    Copy code
    type User {
      id: ID! @unique
      accounts: [Account!]!
    }
    
    type Account {
      id: ID! @unique
    }
    I’ve updated to
    prisma:1.14
    (also tried `prisma:1.15.0-beta`&
    prisma:1.16-alpha
    ) and I’m missing
    connect
    api:
    Copy code
    mutation {
      updateUser(
        where: { id: "123" },
        data: { accounts: { connect: { id: "123" } } }
      ) {
        id
      }
    }
    there is only create and I didnt find way how to connect existing nodes (rows) that already exists thanks 🙂
  • c

    catalinmiron

    08/22/2018, 10:43 AM
    Try
    Copy code
    type User {
      id: ID! @unique
      accounts: [Account!]! @relation(name: "UserAccounts")
    }
    
    type Account {
      id: ID! @unique
    }
    🙌🏻 1
  • c

    catalinmiron

    08/22/2018, 10:46 AM
    Check: https://www.prisma.io/docs/reference/service-configuration/data-modelling-(sdl)-eiroozae8u#relations for further reading. You can't connect types without having a relation.
  • p

    playerx

    08/22/2018, 10:59 AM
    thanks @catalinmiron for your response, but I used already
    @relation
    without any success, there is still only
    create
    api, I think issue Im having its not related to using
    @relation
    directive in this case
  • p

    playerx

    08/22/2018, 11:06 AM
    let me share real use case that I’ve:
    Copy code
    type MusicChannel {
    	id: ID! @unique
    	name: String! @unique
    	logoUrl: String!
    	isFeatured: Boolean!
    	status: MusicChannelStatus!
    
    	activeSource: MusicChannelSource @relation(name: "MusicChannelActiveSource")
    	sources: [MusicChannelSource!]! @relation(name: "MusicChannelSources")
    }
    
    enum MusicChannelStatus {
    	ACTIVE
    	DISABLED
    }
    
    type MusicChannelSource {
    	streamUrl: String!
    	isOffline: Boolean!
    
    	channel: MusicChannel! @relation(name: "MusicChannelActiveSource")
    	songs: [Song!]!
    	ignoreTitles: [String!]!
    }
    and I found the issue 🙂 I didn’t set id field for
    MusicChannelSource
    because it was generated automatically, but it caused this api generation issue for me 🙂 with
    Copy code
    type MusicChannelSource {
    	id: ID! @unique
    	streamUrl: String!
    	isOffline: Boolean!
    
    	channel: MusicChannel! @relation(name: "MusicChannelActiveSource")
    	songs: [Song!]!
    	ignoreTitles: [String!]!
    }
    everything works ok thanks @catalinmiron for your time one more time
  • c

    catalinmiron

    08/22/2018, 11:29 AM
    👍
  • r

    rikki

    08/22/2018, 3:28 PM
    Sin_titulo.js
  • r

    rikki

    08/22/2018, 3:29 PM
    it appears to work the same, and i found it advantageous as it exposes the resolver
  • r

    rikki

    08/22/2018, 3:30 PM
    but i feel like I'm probably missing something?
  • c

    catalinmiron

    08/22/2018, 3:41 PM
    Yes, the only difference is
    Copy code
    const resolvers = {
    	Query: {
        	users: forwardTo('db'),
    	},
    }
    instead of
    Copy code
    const resolvers = {
    	Query: {
        	posts: forwardTo('db'),
    	},
    }
    🙂
  • r

    rikki

    08/22/2018, 3:48 PM
    haha, woops! yeah i had just copied the
    forwardTo
    example over, just noticed it was available
  • r

    rikki

    08/22/2018, 3:50 PM
    this is incredibly powerful by the way, prisma, amazing work to whoever here helped make this
    z
    • 2
    • 1
  • r

    rikki

    08/22/2018, 3:53 PM
    the last time i was able to do much with composing graphql services, there was only really
    graphql-js
    at the time, so apollo/etc all of this is stellar
  • a

    aria

    08/22/2018, 5:23 PM
    Hey, I just learned about Prisma, and I have a quick question. Is it possible to have a field in your datamodel that doesn't directly exist in the db, but is computed arbitrarily in a resolver? I googled around for custom/computed resolvers and wasn't able to find an answer for this.
  • a

    aria

    08/22/2018, 5:25 PM
    For a contrived example, what if I wanted to add some field to a user called
    has_commented_100_times
    , which doesn't exist in the DB, but in the resolver you query for the number of comments associated with them and return true if it's >= 100
    d
    r
    • 3
    • 47
  • r

    rikki

    08/22/2018, 5:47 PM
    @Aria i'ved wondered about this as well, and I know I've seen it implemented somewhere before. this would be graphql-yoga specific
  • w

    wesbos

    08/22/2018, 6:01 PM
    Having trouble deploying right now - is there something going on or am I just a bad dev 😄
    💩 1
  • w

    wesbos

    08/22/2018, 6:02 PM
    “Whoops. Looks like an internal server error. Search your server logs for request ID: us1managementcjl5g30ymerx30b77gqupdrlm”,
    👍 1
    l
    c
    n
    • 4
    • 26
  • c

    catalinmiron

    08/22/2018, 7:21 PM
    Heads up: When adding
    @default
    don't forget to always add the value in double-quotes. Source: https://www.prisma.io/docs/1.4/reference/service-configuration/data-modelling-(sdl)-eiroozae8u/#default-value
    👍 1
  • a

    aroman

    08/22/2018, 11:29 PM
    I have been getting this error. Has anyone ran into it? `request to http://localhost:4466/ failed, reason: socket hang up`… Sounds like something in docker, however I have tried other mutations from playground and I see no issue
    a
    • 2
    • 2
  • z

    zak.singh

    08/23/2018, 2:01 AM
    Is there any ETA on the
    avg
    aggregation? (https://github.com/prisma/prisma/issues/1312) If not, would the best workaround be to just write a SQL query for it?
    l
    f
    • 3
    • 3
  • k

    Khoa Huynh

    08/23/2018, 2:30 AM
    hello guys, how can we pass object arguments with whatever properties into mutation or query functions? @nilan
    • 1
    • 1
  • k

    kratam

    08/23/2018, 9:16 AM
    Let's say I have a type with
    latitude
    and
    longitude
    properties. Is it possible to query them based on a distance from a certain coordinate?
  • k

    kratam

    08/23/2018, 9:18 AM
    Since they're 2 separate properties, I can't even use
    orderBy
    . Do I have to query for every item and do the sorting on the server?
    m
    • 2
    • 3
  • c

    catalinmiron

    08/23/2018, 9:54 AM
    @kratam there's an upcoming connector for ElasticSearch which is going to help you out. https://github.com/prisma/prisma/issues/1665. But definitely you can approximate the lng/lat based on a radius let's say. You can use a lib like https://www.npmjs.com/package/geolib and get the max/min for lng and lat and do a query based on the results.
    👍 2
  • c

    catalinmiron

    08/23/2018, 10:01 AM
    Something like this:
  • c

    catalinmiron

    08/23/2018, 10:01 AM
    Copy code
    const locationCoord = {latitude: 52.516272, longitude: 13.377722}; 
    const radius = 2000; // 2km, 2000m
    const currentlocationCoord = geolib.getBoundsOfDistance(locationCoord, radius);
    const {maxLat, maxLng, minLat, minLng} = geolib.getBounds(currentlocationCoord)
    
    query {
        getLocations(where: {
            latitude_gt: minLat,
            latitude_lt: maxLat,
            longitude_gt: minLng,
            longitude_lt: maxLng
        }) {
            id
        }
    }
    👍 1
    k
    a
    • 3
    • 9
1...104105106...637Latest