question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Return multiple entities from mutation?

See original GitHub issue

Thanks for resolving #50 so fast!

But now i have a new issue. I have the following mutation:

[GraphQLMutation]
public async Task<Expression<Func<DatabaseContext, IQueryable<Device>>>> ScanForDevices(Empty parameters, IJobManager jobManager)
{
	var ids = await jobManager.StartWaitAsync<IEnumerable<int>, IDetectDeviceCommand>(ddc => ddc.ScanAsync()).ConfigureAwait(false);
	return ctx => ctx.Devices.Where(x => ids.Contains(x.Id));
}

Where i try to return multiple Devices, but the schema only seems to indicate that i want to return 1.

{
  "name": "scanForDevices",
  "description": null,
  "args": [],
  "type": {
	"kind": "OBJECT",
	"name": "Device",
	"ofType": null
  },
  "isDeprecated": false,
  "deprecationReason": null
},

I guess my expected output is: (If this is valid GraphQL)

{
  "name": "scanForDevices",
  "description": null,
  "args": [],
  "type": {
	"kind": "LIST",
	"name": null,
	"ofType": {
	  "kind": "OBJECT",
	  "name": "Device",
	  "ofType": null
	}
  },
  "isDeprecated": false,
  "deprecationReason": null
},

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
lukemurraycommented, Jun 4, 2020

Pushed a fix for this. beta3 too.

1reaction
lukemurraycommented, May 31, 2020

Having a look at this now, it seems along the way I have mixed a few things. 1. needing to know the singular type e.g. Movie[] -> Movie for things like looking up fields on Movie and knowing the actual type e.g. Movie[]. Going to try to clean this up

Read more comments on GitHub >

github_iconTop Results From Across the Web

graphql multiple mutations using prior mutation return ...
I understand that mutations are sequential, so it makes sense to me that if Mutation 1 creates an entity and returns an id,...
Read more >
Is it possible to return two "things" from a graphql mutation ...
Hey Alex - yeah absolutely. You can return whatever you want from a GraphQL mutation as long as you specify it in the...
Read more >
Multiple Mutations in a Request | Hasura GraphQL Docs
If multiple mutations are part of the same request, they are executed sequentially in a single transaction. If any of the mutations fail,...
Read more >
How to Return Multiple Entities in JPA Query
In this short tutorial, we'll see how to return multiple different entities in JPA Query. First, we'll create a simple code example ...
Read more >
What is a mutation? - GraphQL Tutorials
When the mutation modifies multiple objects, it can return all of those objects · Mutations can't return modified types directly · To make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found