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

Error CS0122: QueryBuilderParameter<StringOperationFilterInput>.QueryBuilderParameter(string, string, StringOperationFilterInput is inaccessible due to its protection level #108

Open
arjandouwes opened this issue Jul 20, 2022 · 1 comment

Comments

@arjandouwes
Copy link

Used NuGet Packages:

  • GraphQlClientGenerator version 0.9.9
  • GraphQl.Client version 5.0.2
  • GraphQL.Client.Serializer.Newtonsoft version 5.0.2

Used Language: C# 10 .NET 6 (VS 2022 professional version 17.2.6)

I am trying to create the following query using the generated classes from GraphQlClientGenerator:

{ swReleases(where: {swreleaseCode:{ contains : "216"}}) 
 {
    swreleaseDescription
    swreleaseCode
 }
}

The query is being constructed as follows:

 SwreleaseFilterInput swreleaseFilterInput = new()
 {
      Swreleasecode= new(
                    "swreleaseCode",
                    GraphQlTypes.Swrelease,
                    new StringOperationFilterInput()
                    {
                        Contains = new QueryBuilderParameter<string?>(
                                        "swreleaseCode",
                                        GraphQlTypes.Swrelease,
                                        "216")
                    })
            };

   QueryBuilderParameter<SwreleaseFilterInput?> queryBuilderParameter = new(
                                                                     "swreleaseCode",
                                                                      GraphQlTypes.Swrelease,
                                                                      new QueryBuilderParameter<SwreleaseFilterInput> (
                                                                           "swreleaseFilterInput ", 
                                                                           nameof(swreleaseFilterInput), 
                                                                           swreleaseFilterInput));

SwreleaseQueryBuilder swreleaseQueryBuilder = new SwreleaseQueryBuilder().WithAllScalarFields();

QueryQueryBuilder queryQueryBuilder = new QueryQueryBuilder()
                                                    .WithSwReleases(swreleaseQueryBuilder, where: queryBuilderParameter);
var queryString = queryQueryBuilder.Build(Formatting.Indented);
GraphQL.GraphQLRequest swreleaseQuery = new()
{
    Query = queryString,
};
// call to the GraphQL endpoint and response processing code follows

The problem is that

new QueryBuilderParameter<string?>(...) 

produces Error CS0122: QueryBuilderParameter<string?>.QueryBuilderParameter(string, string, StringOperationFilterInput is inaccessible due to its protection level. When checking the generated base class, I found:

public class QueryBuilderParameter<T> : QueryBuilderParameter
{
...
 protected QueryBuilderParameter(string name, string graphQlTypeName, T value) : base(name, graphQlTypeName, value)
}

I have 2 questions:

  1. What is the correct way for constructing the above query using the generated classes?
  2. Should the constructor QueryBuilderParameter(string name, string graphQlTypeName, T value): base(name, graphQlTypeName, value) be decorated with the access modifier protected?
@Husqvik
Copy link
Owner

Husqvik commented Jul 20, 2022

could you provide the API metadata JSON? So I have the exact code available. Or just URL to the API if it's public.

you can retrieve the metadata by querying

query IntrospectionQuery {
    __schema {
      queryType { name }
      mutationType { name }
      subscriptionType { name }
      types {
        ...FullType
      }
      directives {
        name
        description
        locations
        args {
          ...InputValue
        }
      }
    }
  }

  fragment FullType on __Type {
    kind
    name
    description
    fields(includeDeprecated: true) {
      name
      description
      args {
        ...InputValue
      }
      type {
        ...TypeRef
      }
      isDeprecated
      deprecationReason
    }
    inputFields {
      ...InputValue
    }
    interfaces {
      ...TypeRef
    }
    enumValues(includeDeprecated: true) {
      name
      description
      isDeprecated
      deprecationReason
    }
    possibleTypes {
      ...TypeRef
    }
  }

  fragment InputValue on __InputValue {
    name
    description
    type { ...TypeRef }
    defaultValue
  }

  fragment TypeRef on __Type {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
            ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }

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