Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to call type.AddListField with parameters #43

Closed
fabiodr opened this issue Sep 27, 2016 · 7 comments
Closed

Question: how to call type.AddListField with parameters #43

fabiodr opened this issue Sep 27, 2016 · 7 comments

Comments

@fabiodr
Copy link

fabiodr commented Sep 27, 2016

Is it possible to define a type field with parameters, like with schema? I'm not getting the syntax right.

Someting like the example below, but for GraphQLTypeBuilder:

GraphQLSchema<EfContext> schema;

schema.AddListField("accountsByGuid", new { guid = Guid.Empty }, (db, args) => db.Accounts.AsQueryable().Where(a => a.SomeGuid == args.guid));

Thanks in advance

@chkimes
Copy link
Owner

chkimes commented Sep 27, 2016

Hi Fabio,

Well this is embarrassing. I believe at one point we had that overload, but I may have removed it during an overzealous refactoring. I can work on getting it added back in.

@fabiodr
Copy link
Author

fabiodr commented Sep 27, 2016

Good to know! then it must be somewhere in git history :)

@fabiodr
Copy link
Author

fabiodr commented Sep 27, 2016

Fast one.. thanks!! =)

Just another question: can i use GraphiQl client with this solution?

@chkimes
Copy link
Owner

chkimes commented Sep 27, 2016

This should be available on NuGet now. The usage looks like:

typeBuilder.AddListField("someName", new { argField = 0 },
    (db, args, entity) => entity.OtherThings.Where(t => t.Field == args.argField));

Note that the lambda has 3 arguments, first for your context, second for your args, and third for the entity that the field is being referenced from. This is the same for the AddField overload.

@chkimes
Copy link
Owner

chkimes commented Sep 27, 2016

I'm not sure about GraphiQL, I haven't played with it yet. It should just use GraphQL introspection to discover what is available in the schema and we have introspection implemented, so in theory it will work. In practice, introspection hasn't been thoroughly exercised so I can't predict how well it will work.

That said, you could give it a try and let me know what happens.

@fabiodr
Copy link
Author

fabiodr commented Sep 27, 2016

Great, thanks for the usage sample.

About GraphiQl, for sure, i'll try this out and let you know.

@chkimes
Copy link
Owner

chkimes commented Sep 27, 2016

Closing this issue since the new overload is available on NuGet. If something comes up with GraphiQL, let me know in another issue. Thanks!

@chkimes chkimes closed this as completed Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants