https://www.prisma.io/ logo
Join Slack
Powered by
# prisma-whats-new
  • p

    peeter

    01/24/2017, 2:55 PM
    Watch this to understand what globalIds are:

    https://www.youtube.com/watch?v=oPSuvaYmXBY▾

    This is a decent starting point on how to get stuff working: https://github.com/lvarayut/relay-fullstack
  • p

    peeter

    01/24/2017, 2:56 PM
    https://facebook.github.io/relay/graphql/objectidentification.htm
  • c

    codepreneur

    01/24/2017, 2:56 PM
  • p

    peeter

    01/24/2017, 2:56 PM
    That's also pretty important
  • p

    peeter

    01/24/2017, 2:56 PM
    you're trying to query via the store
  • c

    codepreneur

    01/24/2017, 2:56 PM
    right
  • p

    peeter

    01/24/2017, 2:56 PM
    Every item you send out via graphql to relay has a global ID
  • p

    peeter

    01/24/2017, 2:56 PM
    That means, every store item, every video
  • p

    peeter

    01/24/2017, 2:57 PM
    Everything has a globally unique ID
  • p

    peeter

    01/24/2017, 2:57 PM
    Which can be used to query the item via the node interface
  • c

    codepreneur

    01/24/2017, 2:57 PM
  • c

    codepreneur

    01/24/2017, 2:57 PM
    found it
  • c

    codepreneur

    01/24/2017, 2:57 PM
    is this what you wanted?
  • p

    peeter

    01/24/2017, 2:57 PM
    Copy code
    {
     node(id: 123) {
       id
     }
    }
  • p

    peeter

    01/24/2017, 2:57 PM
    Yep
  • p

    peeter

    01/24/2017, 2:57 PM
    Now, to query a video
  • p

    peeter

    01/24/2017, 2:58 PM
    You would do
    Copy code
    {
     node(id: 123) {
       id
       fragment on Video {
    		url
       }
     }
    }
  • c

    codepreneur

    01/24/2017, 2:59 PM
  • c

    codepreneur

    01/24/2017, 2:59 PM
    is this my problem ?
  • c

    codepreneur

    01/24/2017, 2:59 PM
    that I cant query fragment on Video ?
  • p

    peeter

    01/24/2017, 3:01 PM
    Sorry
  • p

    peeter

    01/24/2017, 3:02 PM
    Copy code
    query {
      node(id: 123) {
        id,
        ...F1
      }
    }
    fragment F1 on Video {
    	url
    }
  • p

    peeter

    01/24/2017, 3:02 PM
    Try like that
  • p

    peeter

    01/24/2017, 3:02 PM
    123 should be an actual video ID
  • c

    codepreneur

    01/24/2017, 3:06 PM
  • c

    codepreneur

    01/24/2017, 3:06 PM
    one sec, let me replace video with actual database query
  • c

    codepreneur

    01/24/2017, 3:16 PM
    doesnt matter
  • c

    codepreneur

    01/24/2017, 3:16 PM
    still just returns id
  • c

    codepreneur

    01/24/2017, 3:16 PM
    Copy code
    class Store {}
    class Video {}
    let store = new Store()
    let video = new Video()
    
    let nodeDefs = nodeDefinitions(
      (globalId) => {
        let type = fromGlobalId(globalId).type
        let id = fromGlobalId(globalId).id
        if (type === 'Store') {
          return store
        }
        if (type === 'Video') {
          console.log('type Video!!!!!')
          return docClient.query(
            Object.assign(
              {},
              {TableName: pokemonTable},
              {KeyConditionExpression: 'id = :id'},
              {ExpressionAttributeValues: { ':id': id }}
            )
          ).promise().then(dataToConnection)
        }
        return null
      },
      (obj) => {
        if (obj instanceof Store) {
          return storeType
        }
        if (obj instanceof Video) {
          console.log('instanceof Video!!!')
          return videoType
        }
        return null
      }
    )
  • c

    codepreneur

    01/24/2017, 3:16 PM
    console logs dont appear on the server logs either..
1...878889...637Latest