Skip to content

Support loading ecto conditionally [Partial Solution] #32

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

Conversation

cgiffard
Copy link
Contributor

Including graphql_relay in projects which do not use ecto causes problems, because the ecto dependency here is only required for :test and dev, and is not installed by Mix by default when including graphql_relay as a dependency. This means that the application won't boot, as it can't find :ecto on launch.

This PR solves the problem for environments other than :test and :dev, but does not resolve the case where graphql_relay is used in the :test environment of a project which does not use ecto. In that instance (as is the case with my own project) I'm currently forced to include ecto to satisfy the child dependency, even though my own project doesn't use it. I'm not sure how to resolve this — unless there's an elusive Mix.included_as_a_dependency (etc.) method that I've missed, which would enable more precise control over app loading!

Including graphql_relay in projects which do not use ecto causes problems,
because the ecto dependency here is only required for test, and is not installed
by Mix by default when including graphql_relay as a dependency. This means
that the application won't boot, as it can't find :ecto on launch.
@seanabrahams
Copy link
Member

@cgiffard Thanks for not only reporting your issue but also including a PR.

Your issue is most likely due to including :graphql_relay in your applications list in your mix.exs file. Since graphql_relay does not implement Elixir's Application behaviour this isn't needed. You need to update your list of applications and remove :graphql_relay.

Something like this:

  def application do
    [applications: [:logger, :graphql_relay]]
  end

Becomes this:

  def application do
    [applications: [:logger]]
  end

This should fix your problem. Let me know!

@cgiffard
Copy link
Contributor Author

Thanks, I hadn't actually gotten started with the module yet, and naively assumed it implemented the application behaviour! That helps.

This PR might still be relevant at least for aligning the dependency environments to the manner as loaded in the rest of the application — or am I incorrect there too?

Thanks again for your assistance, and for being so patient with me!

@seanabrahams seanabrahams merged commit f13a251 into graphql-elixir:master Nov 28, 2016
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