Code Monkey home page Code Monkey logo

Comments (70)

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

@Tructivity Can you confirm that you used the Amplify CLI to create the backend for your web App? If so can you share the original schema file that you used in you web app so I can look into reproducing this issue? The one you shared seems pulled from AppSync correct?

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

@Tructivity I am working on reproducing the issue. Will get back to you with update early next week

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

@Tructivity Please see below my findings :

When I use the code gen command for the flutter app I get errors in the code generated files themselves.

Screenshot 2024-02-02 at 12 27 34 PM

To get rid of the errors I updated the schema as below:

  1. Added @model where needed => Check this docs page to learn what happens when its used,
  2. Removed the underscore _ from model names => the _ on the model names collides with dart's private variable naming convention.
  3. You had few boolean fields name bool => renamed that to something else

image

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

@Tructivity Here is the schema file
schema.graphql.zip

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

Yes if you are planning to use the same backend for both

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024 1

@Tructivity You had few fields named bool I renamed those to something like boolFlag

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity we are happy to help resolve errors and knowledge gaps, but your proposed method is inappropriate for this platform.

Let us help you by providing the minimal reproducible code and relevant error messages.

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

I tried everything and didn't work

Please provide specifics on what issue you are facing and we can offer better assitance.

What happened in the Flutter app when using the schema file provided by @offlineprogrammer?

Were you able to deploy the schema?

Were you able to make any requests?

Did you see any errors?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity since you are coming from an non-Amplify web app we can't guarantee that your schema file will be reusable in an Amplify Flutter project.

Amplify Flutter is an abstraction on top of services like AppSync and as such we expect certain aspects of the schema to be formatted a particular way, the Amplify way. For the schema file, we have clear definitions and requirements outlined in our documentation page.

It would be great if we could support any schema format seamlessly, but in reality, the schema must adhere to the specified requirements. @offlineprogrammer has kindly offered a solution, which you can still customize to suit your business requirements while ensuring the format remains intact.

Kindly keep us informed about the findings of your developer, and we can proceed with the discussion of our next steps.

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1
  1. Have the Flutter app make requests to a Lamba function that handles the data transformation and then call your existing web app backend.

@Tructivity please refer to option 2 of my solutions if you do not want to change the web schema.

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity

does it takes a lot of efforts?

All the options I presented require considerable amounts of effort. I recommended option 1 because the effort is upfront, instead of the ongoing maintenance required in option 2.

Does it takes a lot of energy in Aws so it will be costly?

By nature of adding a new AWS resource it will cost more than solution 1. How much will depend on usage, please refer to the lambda pricing page

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity This is what I suggest, however you cannot seamlessly duplicate the data to the new backend without modifying it.

If you rename properties and models inside the new schema (which will be required for Flutter), the data models will not match. You can preserve the old data by mapping the changed column values to the new schema definition for each entry.

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity that sounds like a good plan.

Note, you do not need to recreate the Cognito backend. Focus on creating a new API backend with your new Flutter schema. Then you can consume your web app's Cognito service by following this guide https://docs.amplify.aws/flutter/build-a-backend/auth/import-existing-resources/

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024 1

@Equartey Ohh so I don't need to create a new cognito right? We've already import it in our project.

So I will only create a new API which will create another Appsync and another DynamoDB.

So half of the work is done already right?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity please reference our documentation page which contains the guides. Consuming an existing backend is fairly similar across languages https://docs.amplify.aws/react-native/build-a-backend/existing-resources/cli/

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024 1

@Tructivity The category you're looking for is DataStore, which provides offline first capabilities. It is separate from the API GraphQL feature. Which uses AppSync and DynamoDB on the backend. For more platform specific questions, please refer to their documentation or open a ticket in their repo: https://github.com/aws-amplify/amplify-js/issues?q=is%3Aopen+is%3Aissue+label%3A%22React+Native%22

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

Hi @Tructivity @mtalhastar,

It appears AppSync is not recognizing the mutation and model you're trying to create.

Did you generate this schema with the Amplify CLI?

If so, please ensure your amplify backend is up to date. You can do this by running amplify push from a project containing your teacherType.

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

@Equartey Yes i am using amplify cli, as you can see in the type mutation there are only three mutations createUser, editUser and deleteUser. That is the reason why teacher mutation isnt working as it isnt defined in schema? If so then i want to use editUser mutation to perform crud with teacher like change in teachers data.

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@mtalhastar

as you can see in the type mutation there are only three mutations createUser, editUser and deleteUser. That is the reason why teacher mutation isnt working as it isnt defined in schema?

Correct, you should see you mutation there and it should be generated for you when using the Amplify CLI. Can you post your schema.graphql file from your projects amplify/ directory?

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

@Equartey this haven't generated any mutation files such as editUser createUser etc.
Ignore the big bold words these are just formatted by GitHub ,these were just comments.

schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}

type Mutation @model{
  # User
  ###---------------------------------------------------------------------
  createUser(bandwidth: Int!, dark: Boolean!, email: String!, endingDate: String!, event: [_eventInput], firstname: String!, homework: [_homeworkInput], lastname: String!, manageCategories_Event: [String], manageCategories_Homework: [String], manageCategories_Task: [String], note: [_noteInput], pageSettings: _pageSettingsInput!, password: String!, regestrationDate: String!, schedule: [_scheduleInput], semester: Int!, semester_1: _eachSemesterInput!, semester_2: _eachSemesterInput!, storage: Int!, task: [_taskInput], teacher: [_teacherInput], timetable: [_timetableInput]): userType
  
  deleteUser(email: String!, id: ID!): String
  
  editUser(bandwidth: Int!, dark: Boolean!, email: String!, endingDate: String!, event: [_eventInput], firstname: String!, homework: [_homeworkInput], id: ID!, lastname: String!, manageCategories_Event: [String], manageCategories_Homework: [String], manageCategories_Task: [String], note: [_noteInput], pageSettings: _pageSettingsInput!, password: String!, regestrationDate: String!, schedule: [_scheduleInput], semester: Int!, semester_1: _eachSemesterInput!, semester_2: _eachSemesterInput!, storage: Int!, task: [_taskInput], teacher: [_teacherInput], timetable: [_timetableInput]): userType
}

type Query @model{
  # User
  ###--------------------------------
  allUsers: [userType!]
  getUserById(id: ID!): userType
}

type Subscription @model{
  # User
  ###----------------------------------------------
  onCreateUser: userType @aws_subscribe(mutations : ["createUser"])
  onDeleteUser: String @aws_subscribe(mutations : ["deleteUser"])
  onEditUser: userType @aws_subscribe(mutations : ["editUser"])
}

# Nested
type _checkedType  @model{
  bool: Boolean!
  date: String!
}
 
# Nested
type _eachSemesterType @model{
  absence: [absenceType]
  #  ( 'always as array' )
  grade: [gradeType]
  #  ( 'always as array' )
  subject: [subjectType]
}

# Nested
type _pageSettingsType @model{
  absences: Boolean!
  events: Boolean!
  grades: Boolean!
  home: Boolean!
  homework: Boolean!
  notes: Boolean!
  schedule: Boolean!
  subjects: Boolean!
  tasks: Boolean!
  teachers: Boolean!
  timetable: Boolean!
}

# Nested
type _topicType  @model{
  colorpicker: String!
  id: ID!
  topicDescrip: String!
  topicTitle: String!
}

# Absence
type absenceType @model{
  date: String!
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

# event
type eventType @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  event: String!
  id: ID!
  location: String!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  time: String
}

# Grade
type gradeType @model{
  #  ( optional )
  course: String
  #  ( optional )
  credit: Float
  date: String!
  grade: String!
  #  ( optional )
  ###other properties
  gradeSystem: String!
  id: ID!
  maxpoints: Float
  #  ( optional )
  note: String!
  subject: String!
  weight: Float
}

# homework
type homeworkType @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  teacher: String!
  time: String
  type: String!
}

# Note
type noteType @model{
  description: String!
  id: ID!
  noteTitle: String!
  # other properties
  topics: [_topicType]
}

# Schedule
type scheduleType @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
  typeValue: String!
}

# Subject
type subjectType @model{
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

# task
type taskType @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  task: String!
  time: String
}

# Teacher
type teacherType @model{
  address: String!
  email: String!
  id: ID!
  name: String!
  officehours: String!
  phone: String!
  website: String!
}

# Timetable
type timetableType @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
}

# User
type userType @model {
  bandwidth: Int!
  dark: Boolean!
  email: String!
  endingDate: String!
  #  ( 'always as array' )
  event: [eventType]
  firstname: String!
  #  ( 'always as array' )
  homework: [homeworkType]
  id: ID!
  lastname: String!
  #  ( 'always as array' )
  manageCategories_Event: [String]
  #  ( 'always as array' )
  manageCategories_Homework: [String]
  #  ( 'always as array' )
  ###EXTRA
  manageCategories_Task: [String]
  #  ( 'always as array' )
  note: [noteType]
  pageSettings: _pageSettingsType!
  password: String!
  regestrationDate: String!
  schedule: [scheduleType]
  semester: Int!
  semester_1: _eachSemesterType!
  semester_2: _eachSemesterType!
  storage: Int!
  #  ( 'always as array' )
  task: [taskType]
  #  ( 'always as array' )
  teacher: [teacherType]
  #  ( 'always as array' )
  timetable: [timetableType]
}

input _absenceInput @model{
  date: String!
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

input _checkedInput @model{
  bool: Boolean!
  date: String!
}

input _eachSemesterInput @model{
  absence: [_absenceInput]
  #  ( 'always as array' )
  grade: [_gradeInput]
  #  ( 'always as array' )
  subject: [_subjectInput]
}

input _eventInput @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  event: String!
  id: ID!
  location: String!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  time: String
}

input _gradeInput @model{
  #  ( optional )
  course: String
  #  ( optional )
  credit: Float
  date: String!
  grade: String!
  #  ( optional )
  ###other properties
  gradeSystem: String!
  id: ID!
  maxpoints: Float
  #  ( optional )
  note: String!
  subject: String!
  weight: Float
}

input _homeworkInput @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  teacher: String!
  time: String
  type: String!
}

input _noteInput @model{
  description: String!
  id: ID!
  noteTitle: String!
  # other properties
  topics: [_topicInput]
}

input _pageSettingsInput @model{
  absences: Boolean!
  events: Boolean!
  grades: Boolean!
  home: Boolean!
  homework: Boolean!
  notes: Boolean!
  schedule: Boolean!
  subjects: Boolean!
  tasks: Boolean!
  teachers: Boolean!
  timetable: Boolean!
}

input _scheduleInput @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
  typeValue: String!
}

input _subjectInput @model{
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

input _taskInput @model{
  #  ( optional )
  category: String!
  #  ( optional )
  ###other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  task: String!
  time: String
}

input _teacherInput  @model{
  address: String!
  email: String!
  id: ID!
  name: String!
  officehours: Int!
  phone: String!
  website: String!
}

input _timetableInput  @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
}

input _topicInput  @model{
  colorpicker: String!
  id: ID!
  topicDescrip: String!
  topicTitle: String!
}

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

Hi @mtalhastar, thank you for providing that extra context.

Given your schema.graphql file, there are quite a few errors with how the data is currently modeled.

  1. @model should only be used for your models, i.e. the types for which Amplify automatically generates DDB tables, queries, mutations, subscriptions, input types, and resolvers.
  2. All the extra top-level types are not required. For example schema and type Subscription @model should be removed. Amplify will generate these top-level types for you.
  3. Same with input types. Amplify will generate these based off the types with @model you define.

There could be advance use cases when you need to define extra definitions, but I don't think this is true for you yet.

Please take some time to review our documentation which explains in more detail how Amplify expects data to be modeled.

Once you have reviewed that doc, refactor your schema.graphql file. I have provided a starting point for you, but please review and ensure it fits your business needs. In this example I have simply removed the extra definitions, I have not altered the model types.

After refactoring is done, push your updates to AppSync like so:

$ amplify codegen models
$ amplify push
updated schema.graphql ```graphql # Nested type _checkedType @model{ bool: Boolean! date: String! }

Nested

type _eachSemesterType @model{
absence: [absenceType]

( 'always as array' )

grade: [gradeType]

( 'always as array' )

subject: [subjectType]
}

Nested

type _pageSettingsType @model{
absences: Boolean!
events: Boolean!
grades: Boolean!
home: Boolean!
homework: Boolean!
notes: Boolean!
schedule: Boolean!
subjects: Boolean!
tasks: Boolean!
teachers: Boolean!
timetable: Boolean!
}

Nested

type _topicType @model{
colorpicker: String!
id: ID!
topicDescrip: String!
topicTitle: String!
}

Absence

type absenceType @model{
date: String!
id: ID!
note: String!
room: String!
subject: String!
teacher: String!
}

event

type eventType @model{

( optional )

category: String!

( optional )

###other properties
checked: [_checkedType]
date: String!
date2: String

( optional )

datesBwDate1NDate2: [String!]
event: String!
id: ID!
location: String!
note: String!
repeat: String!

( optional )

selectedDays_MONTHLY: [String!]

( optional )

selectedDays_WEEKLY: [String!]
subject: String!
time: String
}

Grade

type gradeType @model{

( optional )

course: String

( optional )

credit: Float
date: String!
grade: String!

( optional )

###other properties
gradeSystem: String!
id: ID!
maxpoints: Float

( optional )

note: String!
subject: String!
weight: Float
}

homework

type homeworkType @model{

( optional )

category: String!

( optional )

###other properties
checked: [_checkedType]
date: String!
date2: String

( optional )

datesBwDate1NDate2: [String!]
id: ID!
note: String!
repeat: String!

( optional )

selectedDays_MONTHLY: [String!]

( optional )

selectedDays_WEEKLY: [String!]
subject: String!
teacher: String!
time: String
type: String!
}

Note

type noteType @model{
description: String!
id: ID!
noteTitle: String!

other properties

topics: [_topicType]
}

Schedule

type scheduleType @model{
colorpicker: String!
end: String!

other properties

id: ID!
note: String!
room: String!
start: String!
subject: String!
teacher: String!
time1: String!
time2: String!
title: String!
typeValue: String!
}

Subject

type subjectType @model{
id: ID!
note: String!
room: String!
subject: String!
teacher: String!
}

task

type taskType @model{

( optional )

category: String!

( optional )

###other properties
checked: [_checkedType]
date: String!
date2: String

( optional )

datesBwDate1NDate2: [String!]
id: ID!
note: String!
repeat: String!

( optional )

selectedDays_MONTHLY: [String!]

( optional )

selectedDays_WEEKLY: [String!]
task: String!
time: String
}

Teacher

type teacherType @model{
address: String!
email: String!
id: ID!
name: String!
officehours: String!
phone: String!
website: String!
}

Timetable

type timetableType @model{
colorpicker: String!
end: String!

other properties

id: ID!
note: String!
room: String!
start: String!
subject: String!
teacher: String!
time1: String!
time2: String!
title: String!
}

User

type userType @model {
bandwidth: Int!
dark: Boolean!
email: String!
endingDate: String!

( 'always as array' )

event: [eventType]
firstname: String!

( 'always as array' )

homework: [homeworkType]
id: ID!
lastname: String!

( 'always as array' )

manageCategories_Event: [String]

( 'always as array' )

manageCategories_Homework: [String]

( 'always as array' )

###EXTRA
manageCategories_Task: [String]

( 'always as array' )

note: [noteType]
pageSettings: _pageSettingsType!
password: String!
regestrationDate: String!
schedule: [scheduleType]
semester: Int!
semester_1: _eachSemesterType!
semester_2: _eachSemesterType!
storage: Int!

( 'always as array' )

task: [taskType]

( 'always as array' )

teacher: [teacherType]

( 'always as array' )

timetable: [timetableType]
}

</details>

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024
schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}

type Mutation {
  # User
  #---------------------------------------------------------------------
  createUser(bandwidth: Int!, dark: Boolean!, email: String!, endingDate: String!, event: [_eventInput], firstname: String!, homework: [_homeworkInput], lastname: String!, manageCategories_Event: [String], manageCategories_Homework: [String], manageCategories_Task: [String], note: [_noteInput], pageSettings: _pageSettingsInput!, password: String!, pomodorotimer: _pomodorotimerInput, regestrationDate: String!, schedule: [_scheduleInput], semester: Int!, semester_1: _eachSemesterInput!, semester_2: _eachSemesterInput!, storage: Int!, task: [_taskInput], teacher: [_teacherInput], timetable: [_timetableInput]): userType
  deleteUser(email: String!, id: ID!): String
  editUser(bandwidth: Int!, dark: Boolean!, email: String!, endingDate: String!, event: [_eventInput], firstname: String!, homework: [_homeworkInput], id: ID!, lastname: String!, manageCategories_Event: [String], manageCategories_Homework: [String], manageCategories_Task: [String], note: [_noteInput], pageSettings: _pageSettingsInput!, password: String!, pomodorotimer: _pomodorotimerInput, regestrationDate: String!, schedule: [_scheduleInput], semester: Int!, semester_1: _eachSemesterInput!, semester_2: _eachSemesterInput!, storage: Int!, task: [_taskInput], teacher: [_teacherInput], timetable: [_timetableInput]): userType
}

type Query {
  # User
  #--------------------------------
  allUsers: [userType!]
  getUserById(id: ID!): userType
}

type Subscription {
  # User
  #----------------------------------------------
  onCreateUser: userType @aws_subscribe(mutations : ["createUser"])
  onDeleteUser: String @aws_subscribe(mutations : ["deleteUser"])
  onEditUser: userType @aws_subscribe(mutations : ["editUser"])
}

# Nested
type _checkedType @model{
  bool: Boolean!
  date: String!
}

# Nested
type _eachSemesterType @model{
  absence: [absenceType]
  #  ( 'always as array' )
  grade: [gradeType]
  #  ( 'always as array' )
  subject: [subjectType]
}

# Nested
type _pageSettingsType @model{
  absences: Boolean!
  events: Boolean!
  grades: Boolean!
  homework: Boolean!
  notes: Boolean!
  schedule: Boolean!
  subjects: Boolean!
  tasks: Boolean!
  teachers: Boolean!
  timetable: Boolean!
}

# Nested
type _pomodorotimerType @model{
  breakminutes: Int!
  workminutes: Int!
}

# Nested
type _topicType @model{
  colorpicker: String!
  id: ID!
  topicDescrip: String!
  topicTitle: String!
}

# Absence
type absenceType @model{
  date: String!
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

# event
type eventType  @model{
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  event: String!
  id: ID!
  location: String!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  time: String
}

# Grade
type gradeType @model{
  #  ( optional )
  course: String
  #  ( optional )
  credit: Float
  date: String!
  grade: String!
  #  ( optional )
  #other properties
  gradeSystem: String!
  id: ID!
  maxpoints: Float
  #  ( optional )
  note: String!
  subject: String!
  weight: Float
}

# homework
type homeworkType @model{
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  teacher: String!
  time: String
  type: String!
}

# Note
type noteType @model{
  description: String!
  id: ID!
  noteTitle: String!
  # other properties
  topics: [_topicType]
}

# Schedule
type scheduleType @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
  typeValue: String!
}

# Subject
type subjectType @model{
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

# task
type taskType @model{
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedType]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  task: String!
  time: String
}

# Teacher
type teacherType @model{
  address: String!
  email: String!
  id: ID!
  name: String!
  officehours: String!
  phone: String!
  website: String!
}

# Timetable
type timetableType @model{
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
}

# User
type userType @model{
  bandwidth: Int!
  dark: Boolean!
  email: String!
  endingDate: String!
  #  ( 'always as array' )
  event: [eventType]
  firstname: String!
  #  ( 'always as array' )
  homework: [homeworkType]
  id: ID!
  lastname: String!
  #  ( 'always as array' )
  manageCategories_Event: [String]
  #  ( 'always as array' )
  manageCategories_Homework: [String]
  #  ( 'always as array' )
  #EXTRA
  manageCategories_Task: [String]
  #  ( 'always as array' )
  note: [noteType]
  pageSettings: _pageSettingsType!
  password: String!
  #  ( 'always as array' )
  #pomodoro-timer
  pomodorotimer: _pomodorotimerType
  regestrationDate: String!
  schedule: [scheduleType]
  semester: Int!
  semester_1: _eachSemesterType!
  semester_2: _eachSemesterType!
  storage: Int!
  #  ( 'always as array' )
  task: [taskType]
  #  ( 'always as array' )
  teacher: [teacherType]
  #  ( 'always as array' )
  timetable: [timetableType]
}

input _absenceInput {
  date: String!
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

input _checkedInput {
  bool: Boolean!
  date: String!
}

input _eachSemesterInput {
  absence: [_absenceInput]
  #  ( 'always as array' )
  grade: [_gradeInput]
  #  ( 'always as array' )
  subject: [_subjectInput]
}

input _eventInput {
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  event: String!
  id: ID!
  location: String!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  time: String
}

input _gradeInput {
  #  ( optional )
  course: String
  #  ( optional )
  credit: Float
  date: String!
  grade: String!
  #  ( optional )
  #other properties
  gradeSystem: String!
  id: ID!
  maxpoints: Float
  #  ( optional )
  note: String!
  subject: String!
  weight: Float
}

input _homeworkInput {
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  subject: String!
  teacher: String!
  time: String
  type: String!
}

input _noteInput {
  description: String!
  id: ID!
  noteTitle: String!
  # other properties
  topics: [_topicInput]
}

input _pageSettingsInput {
  absences: Boolean!
  events: Boolean!
  grades: Boolean!
  homework: Boolean!
  notes: Boolean!
  schedule: Boolean!
  subjects: Boolean!
  tasks: Boolean!
  teachers: Boolean!
  timetable: Boolean!
}

input _pomodorotimerInput {
  breakminutes: Int!
  workminutes: Int!
}

input _scheduleInput {
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
  typeValue: String!
}

input _subjectInput {
  id: ID!
  note: String!
  room: String!
  subject: String!
  teacher: String!
}

input _taskInput {
  #  ( optional )
  category: String!
  #  ( optional )
  #other properties
  checked: [_checkedInput]
  date: String!
  date2: String
  #  ( optional )
  datesBwDate1NDate2: [String!]
  id: ID!
  note: String!
  repeat: String!
  #  ( optional )
  selectedDays_MONTHLY: [String!]
  #  ( optional )
  selectedDays_WEEKLY: [String!]
  task: String!
  time: String
}

input _teacherInput {
  address: String!
  email: String!
  id: ID!
  name: String!
  officehours: String!
  phone: String!
  website: String!
}

input _timetableInput {
  colorpicker: String!
  end: String!
  # other properties
  id: ID!
  note: String!
  room: String!
  start: String!
  subject: String!
  teacher: String!
  time1: String!
  time2: String!
  title: String!
}

input _topicInput {
  colorpicker: String!
  id: ID!
  topicDescrip: String!
  topicTitle: String!
}

@Equartey I made changes to schema and generated models but there are no mutation files appearing

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

Cant i do it without generating models and mutations ,just with simple graphql query written in string as api request.

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

@Equartey i dont use amplify models in fetching the data just simple api request, how can i do this for creating editing mutations of a user. thanks
image

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@mtalhastar

In order to run a GraphQL request with a raw string, you first need to define and deploy your models to AppSync.

Where is this schema located that you provided?

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

The GraphQL schema is already deployed in App sync but that schema don't have @model with them as it was made for web frontend. My flutter app is connected with same amplify backend, i can fetch the data but don't know how to create update or delete using raw string approach.

The second last schema is sent is of flutter app to generate models and mutations.
but generating codegen models haven't created any mutation files, it only generated model files.

The following schema is on AppSync for web:

input _absenceInput {
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	date: String!
}

input _checkedInput {
	date: String!
	bool: Boolean!
}

#Nested
type _checkedType {
	date: String!
	bool: Boolean!
}

input _eachSemesterInput {
	absence: [_absenceInput]
	# ( 'always as array' )
	subject: [_subjectInput]
	# ( 'always as array' )
	grade: [_gradeInput]
}

#Nested
type _eachSemesterType {
	absence: [absenceType]
	# ( 'always as array' )
	subject: [subjectType]
	# ( 'always as array' )
	grade: [gradeType]
}

input _eventInput {
	id: ID!
	event: String!
	subject: String!
	location: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedInput]
}

input _gradeInput {
	id: ID!
	subject: String!
	grade: String!
	weight: Float
	# ( optional )
	note: String!
	date: String!
	maxpoints: Float
	# ( optional )
	credit: Float
	# ( optional )
	course: String
	# ( optional )
	#other properties
	gradeSystem: String!
}

input _homeworkInput {
	id: ID!
	subject: String!
	teacher: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	type: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedInput]
}

input _noteInput {
	id: ID!
	noteTitle: String!
	description: String!
	#other properties
	topics: [_topicInput]
}

input _pageSettingsInput {
	homework: Boolean!
	events: Boolean!
	tasks: Boolean!
	notes: Boolean!
	absences: Boolean!
	teachers: Boolean!
	subjects: Boolean!
	schedule: Boolean!
	timetable: Boolean!
	grades: Boolean!
}

#Nested
type _pageSettingsType {
	homework: Boolean!
	events: Boolean!
	tasks: Boolean!
	notes: Boolean!
	absences: Boolean!
	teachers: Boolean!
	subjects: Boolean!
	schedule: Boolean!
	timetable: Boolean!
	grades: Boolean!
}

input _pomodorotimerInput {
	workminutes: Int!
	breakminutes: Int!
}

#Nested
type _pomodorotimerType {
	workminutes: Int!
	breakminutes: Int!
}

input _scheduleInput {
	title: String!
	start: String!
	end: String!
	#other properties
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	time1: String!
	time2: String!
	colorpicker: String!
	typeValue: String!
}

input _subjectInput {
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
}

input _taskInput {
	id: ID!
	task: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedInput]
}

input _teacherInput {
	id: ID!
	name: String!
	phone: String!
	email: String!
	address: String!
	officehours: String!
	website: String!
}

input _timetableInput {
	title: String!
	start: String!
	end: String!
	#other properties
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	time1: String!
	time2: String!
	colorpicker: String!
}

input _topicInput {
	id: ID!
	topicTitle: String!
	topicDescrip: String!
	colorpicker: String!
}

#Nested
type _topicType {
	id: ID!
	topicTitle: String!
	topicDescrip: String!
	colorpicker: String!
}

#Absence
type absenceType {
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	date: String!
}

#event
type eventType {
	id: ID!
	event: String!
	subject: String!
	location: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedType]
}

#Grade
type gradeType {
	id: ID!
	subject: String!
	grade: String!
	weight: Float
	# ( optional )
	note: String!
	date: String!
	maxpoints: Float
	# ( optional )
	credit: Float
	# ( optional )
	course: String
	# ( optional )
	#other properties
	gradeSystem: String!
}

#homework
type homeworkType {
	id: ID!
	subject: String!
	teacher: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	type: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedType]
}

#Note
type noteType {
	id: ID!
	noteTitle: String!
	description: String!
	#other properties
	topics: [_topicType]
}

#Schedule
type scheduleType {
	title: String!
	start: String!
	end: String!
	#other properties
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	time1: String!
	time2: String!
	colorpicker: String!
	typeValue: String!
}

#Subject
type subjectType {
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
}

#task
type taskType {
	id: ID!
	task: String!
	note: String!
	date: String!
	time: String
	# ( optional )
	category: String!
	repeat: String!
	date2: String
	# ( optional )
	selectedDays_WEEKLY: [String!]
	# ( optional )
	selectedDays_MONTHLY: [String!]
	# ( optional )
	datesBwDate1NDate2: [String!]
	# ( optional )
	#other properties
	checked: [_checkedType]
}

#Teacher
type teacherType {
	id: ID!
	name: String!
	phone: String!
	email: String!
	address: String!
	officehours: String!
	website: String!
}

#Timetable
type timetableType {
	title: String!
	start: String!
	end: String!
	#other properties
	id: ID!
	subject: String!
	teacher: String!
	room: String!
	note: String!
	time1: String!
	time2: String!
	colorpicker: String!
}

#User
type userType {
	id: ID!
	firstname: String!
	lastname: String!
	email: String!
	password: String!
	dark: Boolean!
	bandwidth: Int!
	storage: Int!
	regestrationDate: String!
	endingDate: String!
	semester: Int!
	pageSettings: _pageSettingsType!
	semester_1: _eachSemesterType!
	semester_2: _eachSemesterType!
	schedule: [scheduleType]
	# ( 'always as array' )
	timetable: [timetableType]
	# ( 'always as array' )
	teacher: [teacherType]
	# ( 'always as array' )
	note: [noteType]
	# ( 'always as array' )
	task: [taskType]
	# ( 'always as array' )
	event: [eventType]
	# ( 'always as array' )
	homework: [homeworkType]
	# ( 'always as array' )
	#EXTRA
	manageCategories_Task: [String]
	# ( 'always as array' )
	manageCategories_Event: [String]
	# ( 'always as array' )
	manageCategories_Homework: [String]
	# ( 'always as array' )
	#pomodoro-timer
	pomodorotimer: _pomodorotimerType
}

type Mutation {
	#User
	#---------------------------------------------------------------------
	createUser(
		firstname: String!,
		lastname: String!,
		email: String!,
		password: String!,
		dark: Boolean!,
		bandwidth: Int!,
		storage: Int!,
		regestrationDate: String!,
		endingDate: String!,
		semester: Int!,
		pageSettings: _pageSettingsInput!,
		semester_1: _eachSemesterInput!,
		semester_2: _eachSemesterInput!,
		schedule: [_scheduleInput],
		# ( 'always as array' )
timetable: [_timetableInput],
		# ( 'always as array' )
teacher: [_teacherInput],
		# ( 'always as array' )
note: [_noteInput],
		# ( 'always as array' )
task: [_taskInput],
		# ( 'always as array' )
event: [_eventInput],
		# ( 'always as array' )
homework: [_homeworkInput],
		# ( 'always as array' )
#EXTRA
manageCategories_Task: [String],
		# ( 'always as array' )
manageCategories_Event: [String],
		# ( 'always as array' )
manageCategories_Homework: [String],
		# ( 'always as array' )
#pomodoro-timer
pomodorotimer: _pomodorotimerInput
	): userType
	deleteUser(id: ID!, email: String!): String
	editUser(
		id: ID!,
		firstname: String!,
		lastname: String!,
		email: String!,
		password: String!,
		dark: Boolean!,
		bandwidth: Int!,
		storage: Int!,
		regestrationDate: String!,
		endingDate: String!,
		semester: Int!,
		pageSettings: _pageSettingsInput!,
		semester_1: _eachSemesterInput!,
		semester_2: _eachSemesterInput!,
		schedule: [_scheduleInput],
		# ( 'always as array' )
timetable: [_timetableInput],
		# ( 'always as array' )
teacher: [_teacherInput],
		# ( 'always as array' )
note: [_noteInput],
		# ( 'always as array' )
task: [_taskInput],
		# ( 'always as array' )
event: [_eventInput],
		# ( 'always as array' )
homework: [_homeworkInput],
		# ( 'always as array' )
#EXTRA
manageCategories_Task: [String],
		# ( 'always as array' )
manageCategories_Event: [String],
		# ( 'always as array' )
manageCategories_Homework: [String],
		# ( 'always as array' )
#pomodoro-timer
pomodorotimer: _pomodorotimerInput
	): userType
}

type Query {
	#User
	#--------------------------------
	allUsers: [userType!]
	getUserById(id: ID!): userType
}

type Subscription {
	#User
	#----------------------------------------------
	onCreateUser: userType
		@aws_subscribe(mutations: ["createUser"])
	onDeleteUser: String
		@aws_subscribe(mutations: ["deleteUser"])
	onEditUser: userType
		@aws_subscribe(mutations: ["editUser"])
}

schema {
	query: Query
	mutation: Mutation
	subscription: Subscription
}```

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@mtalhastar

I see, I did not realize you had an existing backend. Let's take a step back.

You do not need to create a new backend for your Flutter project if you already have a JS (web) Project. You also do not need to modify or provide a schema locally in this case.

You can import an existing Amplify backend into your Flutter project. Which will reuse your web schema. Please refer to this docs page: https://docs.amplify.aws/react/build-a-backend/existing-resources/cli/

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey I want to ask u a question:

Can DataStore store the data locally when the user offline and who is already sign in? Then, when he connects with the internet, it will share the data to the cloud.

Does it work like this in the Amplify Datastore?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity

Does it work like this in the Amplify Datastore?

This is a correct summary, however you may want to consider if this is truly needed for your use case.

Sorry to hear about the friction you've experienced so far. We're exploring options to best help you. Can you please clarify that a) you've made the revisions we previously suggested, and b) what the remaining issue is?

We'll provide an update when we can.

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

@Equartey the amplify isn't configured by using amplify studio so there are no present categories, i had to generate the models manually by using this command
npx @aws-amplify/cli codegen models
--model-schema <path-to-schema.graphql>
--target [android|ios|flutter|javascript|typescript]
--output-dir ./

amplify codegen models don't work for me.

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

the error is this again
image

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey can u please see it again what's the problem?

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024

@mtalhastar Did you used Amplify CLI to create the Appsync API for your web App?

The @aws-amplify/cli codegen models command will create everything you need but it looks like you defined your inputs and mutation on your schema

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024

Refer to the two guides here for instructions on connecting to an existing GraphQL API. Notice the simplicity of the schema, and the code generation command will automatically create, edit, and fetch the data.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer The web app was first created and then we tried to link the Flutter app to it. We could do it and fetch the data but when it comes to making operations from the Flutter app such as create, remove, and update, then it makes an error.

You can see the whole conversation from the beginning so you will understand everything.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer yes, we've used the Amplify CLI and my developer @mtalhastar will give u the file today!

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer here is the schema.gql file of my web app developed using Gatsby JS

schema.gql.zip

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@salihgueler Can u please help us figure out the solution?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@khatruong2009 I keep tagging people to help but no one could. Can I please see where the issue is?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer so this is an error from the package itself not from us?

from amplify-flutter.

offlineprogrammer avatar offlineprogrammer commented on June 8, 2024

@Tructivity I can't tell yet. Need to reproduce it first

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer Can u please send me this new schema in a zip file as I did because my developer is so busy and probably won't be able to fix them all because of that.

Also, I don't need to change the schema in the web application right? Since they serve the same purpose but different ways how they understand it Flutter and Gatsby JS.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer Thanks for providing the new schema but please tell me, should I change the schema in the web code or just in Flutter?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer thanks for answering my question, you said before "You had few boolean fields name bool => renamed that to something else" what do u mean? Change them to what? So you've done the whole changing but only thing left?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@offlineprogrammer so in abbreviations, I don't need to change anything right now in this schema file you provided and just use it directly on Flutter and web right?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity please only share the relevant code and errors, not the entire app.

Also please remove any sensitive data or credentials.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey the problem couldn't be fixed and you developers are the one who knows how to fix them that's why I've shared it here.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey what should I do now? I tried everything and didn't work

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey I will talk to my developer @mtalhastar and tell him about the type of error it made but I would like to know that since we could use the same schema in the web app and import it to Flutter and fetch the data then why I can make requests to edit or create or remove the data? Why I should change the schema in Flutter?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey thanks a lot for answering but I have one more question, let's say that we changed the schema and it did work in Flutter, if that happens I don't think I should use this edited one in the web app I mean I don't have to change the version of the schema I've provided in the web app right?

I've asked this question because I want to share the web app with users and if it requires changing later, then it can be a problem when I have users who already have data.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey Also you told me this "since you are coming from an non-Amplify web" while my web app uses Gatsby JS with AWS Amplify and we use app sync, DynamoDB, and cognito in our service.

So what do u mean?

from amplify-flutter.

mtalhastar avatar mtalhastar commented on June 8, 2024

@Equartey you are right that GraphQL schema for web app isn't truly compatible with flutter app. Whenever i tried to call mutations functions such as CRUD operations it always gave error such as i mentioned at start + i always needed to format the models whenever i run codegen models just like @offlineprogrammer did. I believe rightly configuring amplify schema will be problem to all solutions.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@mtalhastar "I believe rightly configuring amplify schema will be problem to all solutions." What do u mean?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity apologies, it wasn't clear that you were using Amplify already on the web app. I now have a better comprehension of the problem you're facing.

The root issue is with the original schema not conforming to Flutter standards, primarily:

  1. Models prefixed with _ => the underscore on the model names collides with dart's private variable naming convention.
  2. Boolean fields named bool => This is a reserved word in flutter which requires renaming to something else.

Those fixes are trivial, but the understandable desire to preserve your data complicates the process. I have three options for you, but they all require a considerable amount of effort.

  1. Migrate your data from the web app to a schema that works with Flutter, enabling both apps to access the same backend.
  2. Have the Flutter app make requests to a Lamba function that handles the data transformation and then call your existing web app backend.
  3. Use an Amplify React Native project in the place of Amplify Flutter to avoid the collisions.

Solution one is my recommendation for achieving a consistent and easily maintainable solution across all platforms. This way you natively benefit from any upstream changes to the backend and preserve your work already on in Flutter.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey thanks for answering, for now I don't have any users so when I fix the schema of Flutter, I should go to AppSync and update the schema there as well and works perfectly?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity if you have no data to preserve, I would suggest you start with a fresh amplify backend inside the Flutter project. Get a working schema. Then you can follow this docs page to consume the backend in your web app. You will also need to make modifications inside your web app to consume the new data.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey let's say I've launched the web app with users and I have dataxnow in the database, what should I do then with Flutter to work without changing the web schema?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey I loved this solution but does it takes a lot of efforts?

Does it takes a lot of energy in Aws so it will be costly?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey What about this solution:

Create a fresh Amplify project with Flutter which will create a second service of Appsync, DynamoDB, and cognito.

Duplicate the data of my users to the second services Appsync, DynamoDB, and cognito.

Connect my web app to the second services Appsync, DynamoDB, and cognito so I won't lose any data.

Remove the first services Appsync, DynamoDB, and cognito.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey the reason I choose this solution is because I want to launch the web app which took me a lot of time to build and it is finished.

So what u said is what I will do and it will make some effort to duplicate the data to move it to the second services then I will make some changes to the web app schema to work with the second services which means I won't loose my users data in the future and it will be preserved and no one will notice an error and it will work right?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

So what u said is what I will do and it will make some effort to duplicate the data to move it to the second services then I will make some changes to the web app schema to work with the second services which means I won't loose my users data in the future and it will be preserved and no one will notice an error and it will work right?

@Tructivity I'm not sure I understand your question. If you successful migrate your data to a Flutter friendly schema, the backend can be shared. The end user should not be effected.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey ok I will create another fresh backend with Flutter.

Then migrate the existing data of the my users to those new services Appsync, DynamoDB, cognito.

Then make some trivial changes to the web app schema and it's code to connect it with those new services Appsync, DynamoDB, cognito created with Flutter.

That's all?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey Since the GraphQL schema of Flutter is different than my Gatsby JS web app then what guaranteed to me that when I try to connect the web app to these newly created schema will work?

It may make errors like Flutter did when we tried to connect it with the web app schema.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey I'm considering the third option which is building the app again using react native so as u know, my service uses Appsync, DynamoDB, and Cognito in AWS Amplify so can u please reference the articles I need to connect these services with react native?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey will the app be offline first if I use Appsync GraphQL? Because I heard some says that you need to use Appsync SDK to make react native app offline first with AWS Amplify.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey yes, I'm using datastore which has the capability of offline first right? Even in react native.

Second question: I want anyone to use my app offline without making an account so all the data in their phone but if he sign up, all the data will be uploaded to the cloud and can sync. Is that possible or only who has account in my app have the ability of offline use so all users of my app should sign up?

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey Can u please answer the above question? I'm waiting for two days!

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity

I'm using datastore which has the capability of offline first right? Even in react native.

Correct.

I want anyone to use my app offline without making an account so all the data in their phone but if he sign up, all the data will be uploaded to the cloud and can sync. Is that possible or only who has account in my app have the ability of offline use so all users of my app should sign up?

I'm unfamiliar with this use case. I imagine you could limit the cloud sync capabilities to a user with an account with a combination of authorization rules and/or selective sync.

from amplify-flutter.

Tructivity avatar Tructivity commented on June 8, 2024

@Equartey I have a question, if I created my app with react native then I had to add new columns in the future in the existing DynamoDB?

Will the mobile app still work correctly and users of my mobile app won't be affected?

Remember, I use Aws Amplify in my service!

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

@Tructivity new columns are additive and are not considered a breaking change.

I'm also going to close this issue as the original problem has been resolved. Please open a new issue or consider joining our discord to ask more questions.

from amplify-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.