byme8 / ZeroQL

C# GraphQL client with Linq-like syntax
MIT License
278 stars 13 forks source link

Prefer Internal over Public for accessibility of generated types #26

Closed be1223 closed 1 year ago

be1223 commented 1 year ago

I'm using ZeroQL generated types in a nuget package which I am mapping to other user-defined types via another Models package.

For this reason I would like to have the ZeroQL generated types be declared as Internal so that these types are restricted to the assembly performing the mapping and not publicly exposed.

Currently I have to manually change all of the public types to internal manually and this change is lost each time the tool is run.

Perhaps it could be an --accessibility flag that's passed to the tool which defaults to public for backwards compatibility

byme8 commented 1 year ago

@be1223, checkout the v3.3.3-preview.6. Now you can control it via --visibility option:

dotnet zeroql generate  -s ./schema.graphql -n TestServer -o ./Generated/GraphQL.g.cs --visibility internal
byme8 commented 1 year ago

Also, now it is possible to do it inside the configuration file.

dotnet zeroql config init
dotnet zeroql generate -c ./zeroql.json

The zeroql.json may look like that:

{
  "$schema": "https://raw.githubusercontent.com/byme8/ZeroQL/main/schema.verified.json",
  "graphql": "./schema.graphql",
  "namespace": "TestServer",
  "clientName": "GraphQLClient",
  "visibility": "Internal",
  "output": "./Generated/GraphQL.g.cs"
}