GraphQlClientGenerator: GRAPHQLGEN1000 error when referencing a project that uses GraphQlClientGenerator

Hi, I came across a problem when using GraphQlClientGenerator across multiple projects that reference each other. I have a library project that references the GraphQlClientGenerator source generator to generate source files from a schema.json file, this works fine. The problem arises when creating a second projects that references the first library project. When trying to build it, i get this error: GRAPHQLGEN1000: Either "GraphQlClientGenerator_ServiceUrl" parameter or GraphQL JSON schema additional file must be specified.

Now, I could copy the schema.json file to this second project and add the GraphQlClientGenerator_ServiceUrl but this would kind of defeat the purpose of having a single library project and it would also mean that I have to do this for each project that references the first one.

I think the problem is that the GraphQlClientGenerator analyzer is added as a dependency to all projects which reference a project with the analyzer added, which causes the source generator to run when it shouldn’t. Do you think this is fixable or can you think of any workaround ?

Thanks !

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (18 by maintainers)

Most upvoted comments

Btw. why do you want to use manual generation instead of source generator?

we own the graphql service. so as part of the tests, we spin up an instance of the graphql service and gen a client proxy to be consumed by clients.

Seems to be simpler than that. Just mark the generator assets as private:

<PackageReference Include="GraphQlClientGenerator" Version="0.8.*" IncludeAssets="analyzers" PrivateAssets="all" />

Temporary solution could be adding this snippet to the parent project file.

<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile">
  <ItemGroup>
    <Analyzer Remove="@(Analyzer)" />
  </ItemGroup>
</Target>

But it will disable all analyzers, not just the client generator. Don’t know how to make that conditional on analyzer name yet.