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

A suggestion split FE types and BE types expectations #52

Open
g-pavlik opened this issue Feb 29, 2024 · 1 comment
Open

A suggestion split FE types and BE types expectations #52

g-pavlik opened this issue Feb 29, 2024 · 1 comment

Comments

@g-pavlik
Copy link

Hey @khamusa, excellent idea!

I see a one problem with the current approach:

it { is_expected.to have_field(:isPublished).of_type("Boolean") }

The string notation of GQL types has it place, but I'd suggest something different:

it { 
  is_expected
    .to have_field(:isPublished)
    .of_type(GraphQL::Types::Boolean) 
    .exposed_as("Boolean")
}

This way you can do both:

  1. Make an explicit specification that this field is of this BE type, and
  2. Make an explicit specification that this field's type is exposed as a type understandable by FE GQL lib.

For example, if I changed the graphql_name of my type, the exposed_as would fail, but of_type would not. Giving you a better picture of what's happening.

I know it's a radical change for a gen that has a version 2 already coming, but I love to discuss this.

Maybe to keep the syntax more stable:

it { 
  is_expected
    .to have_field(:isPublished)
    .of_type("Boolean") 
    .implemented_with(GraphQL::Types::Boolean)
}
@khamusa
Copy link
Owner

khamusa commented Mar 5, 2024

@Pawlik thanks for the suggestion. A syntax such as the one you proposed last is definitely doable, as it'd be fully backwards compatible. I haven't been actively developing this gem lately, but I'll gladly accept a PR ;)

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