Skip to content

Conversation

bzbetty
Copy link
Contributor

@bzbetty bzbetty commented Oct 2, 2022

believe this makes default values in mutaitons work

eg


        [GraphQLMutation]

        public int DefaultValueTest(int valueWithDefault = 8)
        {
            return valueWithDefault;
        }

@bzbetty bzbetty mentioned this pull request Oct 2, 2022
@bzbetty
Copy link
Contributor Author

bzbetty commented Oct 2, 2022

Think this is failing due to another merge. Gets the same Reuse slot error (which seem familiar to me, something about trying to add an Expression type or potentially Task<> to a graphql type.

eg

    public System.Threading.Tasks.Task<int?> FirstUserId => System.Threading.Tasks.Task.FromResult(Users.FirstOrDefault()?.Id);

@lukemurray
Copy link
Collaborator

Can we add a test/check that the schema/introspection is generating the default values too?

@bzbetty
Copy link
Contributor Author

bzbetty commented Oct 4, 2022

added in tests/code for sdl/introspection default values

@bzbetty
Copy link
Contributor Author

bzbetty commented Oct 4, 2022

added a couple more SDL default values checks which requires some form of serialisation, used a json serialiser but it's not quite right, so need another method.

eg
schema.Query().AddField("user", new { user = new UserInputObject() { Name = "Steve" } }, (ctx, param) => ctx.Users.FirstOrDefault(), "Return a user by ID");
should become

Assert.Contains("user(user: userInput = { name:\"Steve\"}): User", schema.ToGraphQLSchemaString());
but is currently

Assert.Contains("user(user: userInput = { \"name\":\"Steve\"}): User", schema.ToGraphQLSchemaString());
which isn't valid SDL.

seems to work for enums, integers, booleans, and empty arrays though.

Are you aware of a serializer more suitable?

@bzbetty bzbetty force-pushed the methodDefaultValue branch 4 times, most recently from 01bf1b8 to 30e9ccb Compare October 5, 2022 09:43
@bzbetty bzbetty force-pushed the methodDefaultValue branch from 30e9ccb to 320add1 Compare October 5, 2022 09:50
@lukemurray
Copy link
Collaborator

My most hated test too :P Need to look at changing it some how..

Thanks though

@lukemurray lukemurray merged commit e0408eb into EntityGraphQL:master Oct 10, 2022
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

Successfully merging this pull request may close these issues.

2 participants