Skip to content

No documentation examples of nested fields with arguments.  #6

@birdiesanders

Description

@birdiesanders

I cannot seem to figure out how to satisfy the webpack compiler nor the tooling used to build the schema so that it will let me have arguments on nested fields.

location: {
description: 'A query allowing search of Inventory Locations',
type: new GraphQLList(Location),
args: {
id: {
type: GraphQLInt,
},
locationName: {
description: 'The Location Name to search for.',
type: GraphQLString,
},
offset: {
description: 'The offset for the database query, for example 10 would return results 11 and beyond.',
type: GraphQLInt,
},
limit: {
description: 'The row limit, for example, setting this to 25 will return a maximum of 25. When combined with offset, can be used to paginate.',
type: GraphQLInt,
},
},
resolve(root, args) {
return InventoryDb.models.location.findAll({
include: [
{
model: InventoryDb.models.inventoryItem,
// limit: args.limit,
// offset: args.offset,
through: {
// model: InventoryDb.models.locationInventory,
attributes: ['locationItemPrice', 'locationItemOnHand'],
},
order: [
['id', 'asc'],
['inventoryItems.id', 'asc'],
],
},
{
model: InventoryDb.models.person,
through: {
model: InventoryDb.models.locationEmployees,
attributes: ['jobTitle'],
},
order: ['id', 'asc'],
},
],
where: args,
order: [
['id', 'asc'],
],
});
},
},

The query :

query{ location(id: 2, limit: 2) { id locationName items(limit:3){ id itemName } } }

I need the arguments for the limit and offset to work, but they are not valid arguments and the query errors.

How should I construct the query schema so that these will function properly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions