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

Add a scalar JSON to graphql and use it for the authenticate params type #798

Closed
wants to merge 2 commits into from

Conversation

pradel
Copy link
Member

@pradel pradel commented Sep 5, 2019

Related to #796, @ozsay you might want to take a look.

Using a JSON scalar for the params argument will allow us to write more services without having to change the graphql schema to support that specific service

@pradel pradel changed the title Add a scalar JSON and use it for the authenticate params type Add a scalar JSON to graphql and use it for the authenticate params type Sep 5, 2019
Copy link
Member

@TimMikeladze TimMikeladze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good.

Needs some documentation about what the json input needs look like for existing authentication types since the AuthenticateParamsInput is removed.

@Urigo
Copy link
Contributor

Urigo commented Sep 5, 2019

what do you think about using JSON from GraphQL Scalars?
https://github.com/urigo/graphql-scalars#usage

@pradel
Copy link
Member Author

pradel commented Sep 6, 2019

@Urigo I saw that you were using graphql-type-json for graphql-scalars, since it's the only custom scalar we are using, I was thinking to just use it directly :)

@ozsay
Copy link
Contributor

ozsay commented Sep 6, 2019

@pradel
I wonder if it can be solved using a typed way with extend...

I kinda solved it (prune to overrides) in https://github.com/ozsay/accounts/tree/graphql-api-2.
I basically refactored the graphql-api package to make it easier to use (but it still in progress since I removed most of the configurable parts).

after the change, if I wanted to add a new service (tested for the code-service in PR), I could add it to its graphql schema:

input AuthenticateParamsInput {
    serviceId: String
    code: String
}

The module mechanism would merge AuthenticateParamsInput to a unified type in the aggregated schema.

Since I'm using the same mechanism as before, I guess it works the same without my changes to graphql-api but I can't verify it.

@pradel
Copy link
Member Author

pradel commented Sep 6, 2019

@ozsay I see, I like the idea, my only concern is that every time you add a service you will have to change the graphql schema meaning more configuration to do for the users.

@pradel
Copy link
Member Author

pradel commented Sep 6, 2019

Since we can actually extend the input in graphql 14.X maybe it's better to not use JSON

@pradel pradel closed this Jul 27, 2020
@pradel
Copy link
Member Author

pradel commented Jul 27, 2020

Extend is the way to go 🚀

@pradel pradel deleted the feature/graphql-json-input branch July 27, 2020 12:18
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.

4 participants