These are chat archives for lenaten/react-native-relay

23rd
Jan 2017
Vaidas Mykolaitis
@codepreneur
Jan 23 2017 00:39

why reusing a connection like so:

const storeType = new GraphQLObjectType({
  name: 'Store',
  fields: () => ({
    id: globalIdField('Store'),

    allVideos: {
      type: allVideos.connectionType,
      args: Object.assign(
        {},
        connectionArgs
      ),
      resolve: (_, args) => {

        return docClient.scan(
          Object.assign(
            {},
            {TableName: pokemonTable},
            paginationToParams(args)
          )
        ).promise().then(dataToConnection)
      }
    },

    Video: {
      type: allVideos.connectionType,
      args: Object.assign(
        {},
        connectionArgs,
        {id: {type: GraphQLString}}
      ),
      resolve: (_, args) => {

        return docClient.query(
          Object.assign(
            {},
            {TableName: pokemonTable},
            {KeyConditionExpression: 'id = :id'},
            {ExpressionAttributeValues: { ':id': args.id }},
            paginationToParams(args)
          )
        ).promise().then(dataToConnection)

gives me errors like so:

-- GraphQL Validation Error -- VideoPage --

File:  /Users/what/src/components/VideoPage.js
Error: Cannot query field "id" on type "VideoConnection".
Source:
> 
>             id
>             ^^^
const videoType = new GraphQLObjectType({
  name: 'Video',
  fields: () => ({
    id: {
      type: new GraphQLNonNull(GraphQLID),
      resolve: (obj) => obj.id
    },
    name: { type: GraphQLString },
    url: { type: GraphQLString }
  })
})

const allVideos = connectionDefinitions({
  name: 'Video',
  nodeType: videoType
})