Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:57
    Shane32 demilestoned #3349
  • 04:57
    Shane32 demilestoned #3349
  • 04:56
    Shane32 closed #3429
  • 04:55
    Shane32 closed #3428
  • 04:23
    Shane32 closed #3417
  • 04:11
    Shane32 synchronize #3417
  • 03:46
    Shane32 synchronize #3417
  • Dec 02 16:39
    sungam3r opened #3434
  • Nov 30 21:14
    sungam3r opened #3433
  • Nov 30 20:52
    Shane32 synchronize #3417
  • Nov 30 20:42
    sungam3r labeled #3432
  • Nov 30 20:00
    Shane32 synchronize #3417
  • Nov 30 19:59
    Shane32 synchronize #3417
  • Nov 30 19:56
    Shane32 synchronize #3417
  • Nov 30 15:05
    nichovski opened #3432
  • Nov 30 07:07
    sungam3r opened #3431
  • Nov 29 15:56
    Shane32 opened #3430
  • Nov 29 07:01
    sungam3r closed #2639
  • Nov 29 06:57
    sungam3r closed #2830
  • Nov 28 22:01
    dependabot[bot] labeled #3429
srs6814
@srs6814
Thank you @joemcbride
Really appreciate it
ShawnAbshire
@ShawnAbshire
@joemcbride That's actually exactly what I ended up doing after digging deeper into the solution! Thanks!
psinghms
@psinghms
Is there any example to dynamically add the queryType instead of predefining it via classes. I have a requirement where tables keeps getting created and I want to read the table schema and create the querytype object dynamically further exposing predefined mutation. Any help would be appreciated.
Oleg26Dev
@Oleg26Dev
Why I do not receive a real object? There is my question graphql-dotnet/graphql-client#362
Dino
@DinoSourcesRex
Hey everyone. I am updating an old project which uses ExposeExceptions when setting up the middleware but as of 5.0.# this has been removed. Does anyone have any docs on this? My google -ing ability is failing me here and I'm not sure what the appropriate course of action is to complete my migration.
        services.AddGraphQL(options =>
                {
                    options.EnableMetrics = false;
                    options.ExposeExceptions = _hostingEnvironment.IsDevelopment();
                })
Dino
@DinoSourcesRex
Ah-ha. Looks like it was moved to AddGraphQL().AddErrorInfoProvider().
Mario Adam
@i-dentify
Hi - given a QueryArgument with a GraphType that has a ListGraphType as a field. How can I enforce, that the ListGraphType must contain at least one value?
Sean Harding
@optimizasean
If I add in authorization in GraphQL and in a request they ask for a field which is not authorized for them, should the request return an error or should it return all fields except for that one? (or in that case put values into that field (null/0/""/"Not Authorized")?
[Example: ^] ask for Users { name, email, password }, am not allowed to see password.
If you are supposed to fail the whole request and provide no data, then maybe I need to look into how one goes about dynamically building queries based on authorization status which doesn't seem like an ideal solution...
gubzoid
@gubzoid
Could someone help me in figuring out how to deprecate an argument, in this case "userId" given this query.
Field<UserSkillsProfileType, UserSkillsProfileResponse>()
                .Name("userSkillsProfile")
                .Description("Get user skills domain profile information")
                .Argument<NonNullGraphType<IntGraphType>>("userId", "user identifier")
                .ResolveAsync(ctx =>
                {
                    var userId = ctx.GetArgument<int>("userId");
                    return userSkillsService.GetByUserId(userId);
                });
ddelapasse2
@ddelapasse2
Hi All! We cannot get our code updated to use V4. Some kind of issue with Newtonsoft's JObject missing the ToInputs method and then we spiraled from there. Anyone know of a working sample project using .net core that we could use for hints?
Joe McBride
@joemcbride
@ddelapasse2 ToInputs is an extension in the GraphQL.NewtonSoftJson Nuget https://github.com/graphql-dotnet/graphql-dotnet/blob/42b83821cbf224848531723d9689df6a2ae30c7c/src/GraphQL.NewtonsoftJson/StringExtensions.cs#L29 You have that nuget package?
Are you upgrading to v4 from 2.4?
Joe McBride
@joemcbride
Link to the 3.x upgrade docs about serialization changes. https://graphql-dotnet.github.io/docs/migrations/migration3#json-parsing-and-serialization
ddelapasse2
@ddelapasse2
image.png
ddelapasse2
@ddelapasse2
We're trying to go from the preview to 3.0 to 4.6. Made it to 3.0, but can't get any further. My string extension method doesn't have ToInputs anymore (it was there prior). I will check the document. Thanks!
Joe McBride
@joemcbride
Right … part of the 3.0 upgrade are new separate serialization nuget packages, one for NewtonSoft and one for System.Text.Json. Need to add one of those to your project.
cheaze
@cheaze
Hi, I am using GraphQL 2.4.0 with GraphQL.Relay 0.5.0. I have been using it successfully for all my needs with serving data to a Gatsby build engine. It's been great.
I have been making use of the ConnectionType in the Relay package.
I need to build a new feature for searching for properties (houses/flats etc), which will return Connection<PropertyType> and take in arguments as parameters, this is all fine and works.
However, in addition to the paged results being returned, my search also needs to be able to return the "facets" of the search.
E.g. Let's say the search returns 40 properties. The facets may say of the 40 results we have "25 houses, 10 flats & 5 bungalows" or "10 properties have 2 bedrooms, 25 have 3 bedrooms, & 5 have 4 bedrooms."
I have this List<Facets> created and returned by the search method and it's ready to go. It's not really part of the property data, it's additional data about the search.
Is there a way to somehow add extra Fields to the Connection? I'd be happy to add this into the PageInfo or as new object on the Connection?
Is this possible, I have tried various things (extending the PageInfoType in my project) but I am struggling to get this going? Is there something clever I am missing?
Thanks!
cpang2
@cpang2
hi, i am trying to use schema first approach for graphql. based on the example given here https://graphql-dotnet.github.io/docs/getting-started/introduction/,
say GetHero returns the results from the repository class. How do I pass in the repository (eg, DatabaseRepository which implements IDatabaseRepository interface) using dependency injection? I cannot seem to find example for schema first approach. Your help is appreciated.
Joe McBride
@joemcbride

@cpang2 You can use constructor injection. So just pass the dependency to the constructor of the Graph Type class.

public class Query
{
    private readonly IDroidRepo _droidRepo;

    public Query(IDroidRepo droidRepo)
    {
        _droidRepo = droidRepo;
    }

    [GraphQLMetadata("droid")]
    public Task<Droid> GetDroid(string id)
    {
        return _droidRepo.GetDroidByIdAsync(id);
    }
}

Make sure your dependency (IDroidRepo in this case) is registered with your DI Container, and the DI container is configured on the Schema.

Joe McBride
@joemcbride
This is what it looks like to register the ServiceProvder with the Schema in schema first in ASP.NET Core.
services.AddTransient<ISchema>(s =>
{
    return Schema.For(@"
        type Droid {
            id: ID!
            name: String!
        }
        type Query {
            droid(id: ID!): Droid
        }
    ", _ =>
    {
        _.ServiceProvider = s;
        _.Types.Include<Query>();
    });
});

This example also shows how to use Authorization, as well as shows how you could have the Schema syntax paired with the .NET class.

graphql-dotnet/examples#66
https://github.com/graphql-dotnet/examples/pull/66/files#diff-ece58d1582d42b863aaa59e00ec82ea7c82d381729cd1eb72120416e2ee4aa52

     [GraphQLMetadata("Query")]
     [GraphTypeMetadata(@"
         extend type Query {
             viewer: User
         }
     ")]
     public class QueryType
     {
         [GraphQLAuthorize("CustomRequirement")]
         public User Viewer()
         {
             return new User { Id = 1, Name = "Quinn" };
         }
     }
cpang2
@cpang2

@joemcbride , is that all is needed in startup class? Do I need the following to add Query in services? Would be great if you can provide a complete solution including Startup class. Thanks!

services.AddSingleton(new Query());

Kevin McGill
@kmcgill88_gitlab
image.png
Hello all, I am using schema first and have hooked graphql up to an azure function. I ran into a strange issue where anytime I pass parameterized variables i get the above error (or similar). Could anyone please point me in the right direction?
image.png
Strange enough if I just hard code the ID into the query things works as I'd expect.
Ashish Nakil
@anakil-mdsol
Hi, do we have any references of schema first approach. Appreciate your help.
Sean Harding
@optimizasean
@joemcbride Is it possible to access the request on authorize with?
What I want to do is achieve resource level authorization based on the user context and the requested resource:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Security.Claims;

using Microsoft.EntityFrameworkCore;

using GraphQL;
using GraphQL.Types;
using GraphQL.Utilities;

namespace GraphQLApp.Mutations {
    public partial class GQLMutation: ObjectGraphType {
        private partial void DoStringThing(ApplicationDbContext context) {
            FieldAsync<StringGraphType>(
                name: "doStringTest",
                arguments: new QueryArguments(
                    new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "input" }
                ),
                resolve: resolver => {
                    return  "Success";
                }
            ).AuthorizeWith("GetStringPolicy", input);
        }
    }
}
Sean Harding
@optimizasean
If I can somehow pass the query arguments (either all or specific ones) to the authorization policy, then I can use one of the query arguments (the resource) to limit the access to the resource if they don't have a claim matching Type: "StringAccessPass", Value: "{GUID_Of_Database_Entity}"

This would allow further control through things like special resource access based on query/mutation parameters to control things such as who can modify or view certain objects or portions of objects.

Good example would be people with the role KeyManager could generate new keys, and they would be assigned KeyOwner:KeyID as a claim since only the generator is allowed to view the key value

Sean Harding
@optimizasean
Is it possible to set the resource of the AuthorizationHandlerContext? Maybe that is the way to go with this
^Set the context.Resource to the GraphQLUserContext or maybe the request so I can pull data off the request...? Hmmm maybe not ideal...if I could just set the resource to something using AuthorizeWith method?
Sean Harding
@optimizasean
In the AuthorizeWith I want to access the GraphQL query arguments such as resolver.GetArgument<type>("name"); And then (that being the resource they want) I can use this to authorize access. Or do I have to do this inside the resolver?
Sean Harding
@optimizasean
Maybe if resource control belongs inside the field for additional authorization...I would like to throw authorizationerror from inside the field
Sean Harding
@optimizasean
No luck, I am just writing policies to check the static resources (i.e. the claims) and then checking the value of the claims inside of the method since I can't figure out how to pass the value to the assertion to check for a claim with a specific value.
Double work, but it does work, although not the most convenient or well thought out
Something nice would be if there was a way to expand the GraphQLUserContext to include the request arguments which could then be set as the resource in the AuthorizationHandlerContext. IF this was done, then resource based authorization could easily be done using claims.
ManaseePatra
@ManaseePatra
Hi joemcbride, we are trying to upgrade the graphql package from 3.3.2 to the latest 4.6.1, the performance is good as mentioned in the release note. But we observed that even the performance is fast facing web socket disconnection issue intermittently. It's working fine with the older version. Can you Please suggest here?
1 reply
Jean-Philippe Tissot
@jptissot
What could cause some resolvers to not be triggerred ? I basically wanted to have something like this : query { topLevel { nodes { id } aggregates { count } } nodes and aggregates are classes that implement FieldType that have a async resolver but they would never get triggered. The top level was a simple ObjectGraphType. If I move the nodes and aggregates at the top level, everything works fine.
Pourya
@PouryaMontakhab
@joemcbride I'm trying to use AutoRegisteringObjectGraphType with nested model .
but I receive an error like this :
The GraphQL type for field 'Person.address' could not be derived implicitly. Could not find type mapping from CLR type 'GraphqlTest.Address' to GraphType. Did you forget to register the type mapping with the 'ISchema.RegisterTypeMapping'?
image.png
EEliyev
@EEliyev
GraphQl v5, Why does this problem occur, Could not load type 'GraphQL.IDocumentWriter' from assembly 'GraphQL, Version=5.3.3.0, Culture=neutral, PublicKeyToken=null'?
image.png
Rachael Savoy
@rachsavoy
Hello, Has anyone used Graphql in Datadog? I am trying to run a multi-step API test.
Hoang Do Van
@hoangdovan
Anyone here think this project API change so fast and so much, not stable at all? Today I have just upgrade from V4 to V7, it's so much breaking change about API! It's not good and not easy for big projects.
Tony Han
@hyzx86
Hello, everyone. I wonder if there is any way to modify the types registered in Graphql? For example, add fields and instructions for a registered type
https://github.com/OrchardCMS/OrchardCore/discussions/12667